Skip to content

Commit

Permalink
review: for old saved swaps check "TakerSwapEvent::MakerPaymentSpent"…
Browse files Browse the repository at this point in the history
… in is_recoverable function
  • Loading branch information
laruh committed Sep 27, 2024
1 parent 0073fe8 commit aed8d4c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mm2src/mm2_main/src/lp_swap/taker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ impl TakerSavedSwap {
if !self.is_finished() {
return false;
};
let mut maker_payment_spent = false;
let mut maker_payment_spend_confirmed_failed = false;
for event in self.events.iter() {
match event.event {
TakerSwapEvent::StartFailed(_)
Expand All @@ -277,9 +279,20 @@ impl TakerSavedSwap {
| TakerSwapEvent::MakerPaymentWaitConfirmFailed(_) => {
return false;
},
TakerSwapEvent::MakerPaymentSpent(_) => {
maker_payment_spent = true;
},
TakerSwapEvent::MakerPaymentSpendConfirmFailed(_) => {
maker_payment_spend_confirmed_failed = true;
},
_ => (),
}
}
// MakerPaymentSpent was the last success event but a new step `MakerPaymentSpendConfirmed` was added after it
// For backward compatibility (old saved swaps) we need to check for MakerPaymentSpent and there is no MakerPaymentSpendConfirmFailed
if maker_payment_spent && !maker_payment_spend_confirmed_failed {
return false;
}
true
}

Expand Down

0 comments on commit aed8d4c

Please sign in to comment.