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:
Thomas Eizinger 2021-04-01 16:38:33 +11:00
parent c0785ab05a
commit 24f444b9f7
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -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;
XmrLockTransferProofSent {
monero_wallet_restore_blockheight,
transfer_proof,
state3,
tokio::select! {
result = event_loop_handle.send_transfer_proof(transfer_proof.clone()) => {
result?;
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 {
monero_wallet_restore_blockheight,
transfer_proof,