mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-29 12:06:35 -05:00
feat: Allow for cooperative Monero redeem after Bitcoin punish has happened
This commit is contained in:
parent
c5aa7edb6b
commit
d7b649b7a6
25 changed files with 548 additions and 101 deletions
|
|
@ -33,6 +33,10 @@ pub enum Bob {
|
|||
EncSigSent {
|
||||
state4: bob::State4,
|
||||
},
|
||||
BtcPunished {
|
||||
state: bob::State6,
|
||||
tx_lock_id: bitcoin::Txid,
|
||||
},
|
||||
BtcRedeemed(bob::State5),
|
||||
CancelTimelockExpired(bob::State6),
|
||||
BtcCancelled(bob::State6),
|
||||
|
|
@ -44,7 +48,6 @@ pub enum BobEndState {
|
|||
SafelyAborted,
|
||||
XmrRedeemed { tx_lock_id: bitcoin::Txid },
|
||||
BtcRefunded(Box<bob::State6>),
|
||||
BtcPunished { tx_lock_id: bitcoin::Txid },
|
||||
}
|
||||
|
||||
impl From<BobState> for Bob {
|
||||
|
|
@ -79,13 +82,11 @@ impl From<BobState> for Bob {
|
|||
BobState::BtcRedeemed(state5) => Bob::BtcRedeemed(state5),
|
||||
BobState::CancelTimelockExpired(state6) => Bob::CancelTimelockExpired(state6),
|
||||
BobState::BtcCancelled(state6) => Bob::BtcCancelled(state6),
|
||||
BobState::BtcPunished { state, tx_lock_id } => Bob::BtcPunished { state, tx_lock_id },
|
||||
BobState::BtcRefunded(state6) => Bob::Done(BobEndState::BtcRefunded(Box::new(state6))),
|
||||
BobState::XmrRedeemed { tx_lock_id } => {
|
||||
Bob::Done(BobEndState::XmrRedeemed { tx_lock_id })
|
||||
}
|
||||
BobState::BtcPunished { tx_lock_id } => {
|
||||
Bob::Done(BobEndState::BtcPunished { tx_lock_id })
|
||||
}
|
||||
BobState::SafelyAborted => Bob::Done(BobEndState::SafelyAborted),
|
||||
}
|
||||
}
|
||||
|
|
@ -123,11 +124,11 @@ impl From<Bob> for BobState {
|
|||
Bob::BtcRedeemed(state5) => BobState::BtcRedeemed(state5),
|
||||
Bob::CancelTimelockExpired(state6) => BobState::CancelTimelockExpired(state6),
|
||||
Bob::BtcCancelled(state6) => BobState::BtcCancelled(state6),
|
||||
Bob::BtcPunished { state, tx_lock_id } => BobState::BtcPunished { state, tx_lock_id },
|
||||
Bob::Done(end_state) => match end_state {
|
||||
BobEndState::SafelyAborted => BobState::SafelyAborted,
|
||||
BobEndState::XmrRedeemed { tx_lock_id } => BobState::XmrRedeemed { tx_lock_id },
|
||||
BobEndState::BtcRefunded(state6) => BobState::BtcRefunded(*state6),
|
||||
BobEndState::BtcPunished { tx_lock_id } => BobState::BtcPunished { tx_lock_id },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -148,6 +149,7 @@ impl fmt::Display for Bob {
|
|||
Bob::BtcRedeemed(_) => f.write_str("Monero redeemable"),
|
||||
Bob::Done(end_state) => write!(f, "Done: {}", end_state),
|
||||
Bob::EncSigSent { .. } => f.write_str("Encrypted signature sent"),
|
||||
Bob::BtcPunished { .. } => f.write_str("Bitcoin punished"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue