Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(asb): Accept cooperative redeem earlier #156

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion swap/src/asb/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ where
let swap_peer = self.db.get_peer_id(swap_id).await;
let swap_state = self.db.get_state(swap_id).await;

// If we do not find the swap in the database, or we do not have a peer-id for it, reject
let (swap_peer, swap_state) = match (swap_peer, swap_state) {
(Ok(peer), Ok(state)) => (peer, state),
_ => {
Expand All @@ -343,6 +344,7 @@ where
}
};

// If the peer is not the one associated with the swap, reject
if swap_peer != peer {
tracing::warn!(
swap_id = %swap_id,
Expand All @@ -357,7 +359,10 @@ where
continue;
}

let State::Alice (AliceState::BtcPunished { state3 }) = swap_state else {
// If we are in either of these states, the punish timelock has expired
// Bob cannot refund the Bitcoin anymore. We can publish tx_punish to redeem the Bitcoin.
// Therefore it is safe to reveal s_a to let him redeem the Monero
let State::Alice (AliceState::BtcPunished { state3 } | AliceState::BtcPunishable { state3, .. }) = swap_state else {
tracing::warn!(
swap_id = %swap_id,
reason = "swap is in invalid state",
Expand Down
Loading