mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-25 07:29:32 -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())
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
XmrLockTransferProofSent {
|
tokio::select! {
|
||||||
monero_wallet_restore_blockheight,
|
result = event_loop_handle.send_transfer_proof(transfer_proof.clone()) => {
|
||||||
transfer_proof,
|
result?;
|
||||||
state3,
|
|
||||||
|
XmrLockTransferProofSent {
|
||||||
|
monero_wallet_restore_blockheight,
|
||||||
|
transfer_proof,
|
||||||
|
state3,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ = tx_lock_status.wait_until_confirmed_with(state3.cancel_timelock) => {
|
||||||
|
AliceState::CancelTimelockExpired {
|
||||||
|
monero_wallet_restore_blockheight,
|
||||||
|
transfer_proof,
|
||||||
|
state3,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => AliceState::CancelTimelockExpired {
|
}
|
||||||
monero_wallet_restore_blockheight,
|
|
||||||
transfer_proof,
|
|
||||||
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