Avoid problems when re-ordering / changing Bob's states

Make it explicit in which states we are able NOT to cancel/refund.
pull/376/head
Daniel Karzel 3 years ago committed by Thomas Eizinger
parent e6dd194f77
commit d233e9914e
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

@ -26,7 +26,14 @@ pub async fn cancel(
BobState::XmrLocked(state4) => state4.cancel(),
BobState::EncSigSent(state4) => state4.cancel(),
BobState::CancelTimelockExpired(state6) => state6,
_ => bail!(
BobState::Started { .. }
| BobState::ExecutionSetupDone(_)
| BobState::BtcRedeemed(_)
| BobState::BtcCancelled(_)
| BobState::BtcRefunded(_)
| BobState::XmrRedeemed { .. }
| BobState::BtcPunished { .. }
| BobState::SafelyAborted => bail!(
"Cannot cancel swap {} because it is in state {} which is not refundable.",
swap_id,
state

@ -24,7 +24,13 @@ pub async fn refund(
BobState::EncSigSent(state4) => state4.cancel(),
BobState::CancelTimelockExpired(state6) => state6,
BobState::BtcCancelled(state6) => state6,
_ => bail!(
BobState::Started { .. }
| BobState::ExecutionSetupDone(_)
| BobState::BtcRedeemed(_)
| BobState::BtcRefunded(_)
| BobState::XmrRedeemed { .. }
| BobState::BtcPunished { .. }
| BobState::SafelyAborted => bail!(
"Cannot refund swap {} because it is in state {} which is not refundable.",
swap_id,
state

Loading…
Cancel
Save