mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-25 23:49:31 -05:00
Race sending transfer proof against cancel timelock
Sending the transfer proof might never resolve because Bob doesn't come back online. In that case, we need to make sure we bail out as soon as the timelock expires.
This commit is contained in:
parent
c0785ab05a
commit
24f444b9f7
@ -116,29 +116,32 @@ async fn next_state(
|
|||||||
state3,
|
state3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
AliceState::XmrLocked {
|
AliceState::XmrLocked {
|
||||||
monero_wallet_restore_blockheight,
|
monero_wallet_restore_blockheight,
|
||||||
transfer_proof,
|
transfer_proof,
|
||||||
state3,
|
state3,
|
||||||
} => match state3.expired_timelocks(bitcoin_wallet).await? {
|
} => {
|
||||||
ExpiredTimelocks::None => {
|
let tx_lock_status = bitcoin_wallet.subscribe_to(state3.tx_lock.clone()).await;
|
||||||
event_loop_handle
|
|
||||||
.send_transfer_proof(transfer_proof.clone())
|
tokio::select! {
|
||||||
.await?;
|
result = event_loop_handle.send_transfer_proof(transfer_proof.clone()) => {
|
||||||
|
result?;
|
||||||
|
|
||||||
XmrLockTransferProofSent {
|
XmrLockTransferProofSent {
|
||||||
monero_wallet_restore_blockheight,
|
monero_wallet_restore_blockheight,
|
||||||
transfer_proof,
|
transfer_proof,
|
||||||
state3,
|
state3,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
_ => AliceState::CancelTimelockExpired {
|
_ = tx_lock_status.wait_until_confirmed_with(state3.cancel_timelock) => {
|
||||||
|
AliceState::CancelTimelockExpired {
|
||||||
monero_wallet_restore_blockheight,
|
monero_wallet_restore_blockheight,
|
||||||
transfer_proof,
|
transfer_proof,
|
||||||
state3,
|
state3,
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
AliceState::XmrLockTransferProofSent {
|
AliceState::XmrLockTransferProofSent {
|
||||||
monero_wallet_restore_blockheight,
|
monero_wallet_restore_blockheight,
|
||||||
transfer_proof,
|
transfer_proof,
|
||||||
|
Loading…
Reference in New Issue
Block a user