From ce58b8b33377117a3207533a7fb7b413c3df2088 Mon Sep 17 00:00:00 2001 From: rishflab Date: Thu, 2 Sep 2021 13:29:52 +1000 Subject: [PATCH] Handle errors when waiting for subscriptions We were not thorough enough in PR #705 and there were some remaining unhandled errors. Co-authored-by: Daniel Karzel --- CHANGELOG.md | 7 +++++++ swap/src/protocol/alice/swap.rs | 7 +++++-- swap/src/protocol/bob/swap.rs | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36ae9c29..0b1911fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- A bug where the ASB erroneously transitioned into a punishable state upon a bitcoin transaction monitoring error. + This could lead to a scenario where the ASB was neither able to punish, nor able to refund, so the XMR could stay locked up forever while the CLI refunded the BTC. +- A bug where the CLI erroneously transitioned into a cancel-timelock-expired state upon a bitcoin transaction monitoring error. + This could lead to a scenario where the CLI is forced to wait for cancel, even though the cancel timelock is not yet expired and the swap could still be redeemed. + ## [0.8.2] - 2021-09-01 ### Added diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index c3808103..76324667 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -176,7 +176,8 @@ where state3, } }, - _ = tx_lock_status.wait_until_confirmed_with(state3.cancel_timelock) => { + result = tx_lock_status.wait_until_confirmed_with(state3.cancel_timelock) => { + let _ = result?; AliceState::CancelTimelockExpired { monero_wallet_restore_blockheight, transfer_proof, @@ -325,7 +326,9 @@ where state3, } } - _ = tx_cancel_status.wait_until_confirmed_with(state3.punish_timelock) => { + result = tx_cancel_status.wait_until_confirmed_with(state3.punish_timelock) => { + let _ = result?; + AliceState::BtcPunishable { monero_wallet_restore_blockheight, transfer_proof, diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 45c5a3b1..1bb6587a 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -123,7 +123,8 @@ async fn next_state( monero_wallet_restore_blockheight } }, - _ = cancel_timelock_expires => { + result = cancel_timelock_expires => { + let _ = result?; tracing::info!("Alice took too long to lock Monero, cancelling the swap"); let state4 = state3.cancel();