mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04: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,
|
||||
},
|
||||
},
|
||||
|
||||
AliceState::XmrLocked {
|
||||
monero_wallet_restore_blockheight,
|
||||
transfer_proof,
|
||||
state3,
|
||||
} => match state3.expired_timelocks(bitcoin_wallet).await? {
|
||||
ExpiredTimelocks::None => {
|
||||
event_loop_handle
|
||||
.send_transfer_proof(transfer_proof.clone())
|
||||
.await?;
|
||||
} => {
|
||||
let tx_lock_status = bitcoin_wallet.subscribe_to(state3.tx_lock.clone()).await;
|
||||
|
||||
tokio::select! {
|
||||
result = event_loop_handle.send_transfer_proof(transfer_proof.clone()) => {
|
||||
result?;
|
||||
|
||||
XmrLockTransferProofSent {
|
||||
monero_wallet_restore_blockheight,
|
||||
transfer_proof,
|
||||
state3,
|
||||
}
|
||||
}
|
||||
_ => AliceState::CancelTimelockExpired {
|
||||
},
|
||||
_ = tx_lock_status.wait_until_confirmed_with(state3.cancel_timelock) => {
|
||||
AliceState::CancelTimelockExpired {
|
||||
monero_wallet_restore_blockheight,
|
||||
transfer_proof,
|
||||
state3,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AliceState::XmrLockTransferProofSent {
|
||||
monero_wallet_restore_blockheight,
|
||||
transfer_proof,
|
||||
|
Loading…
Reference in New Issue
Block a user