Skip to content

Commit

Permalink
call wait_for_confirmations after send_taker_spends_maker_payment
Browse files Browse the repository at this point in the history
… method in taker_swap.rs
  • Loading branch information
laruh committed Aug 29, 2024
1 parent 932669a commit 17a5fab
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions mm2src/mm2_main/src/lp_swap/taker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,28 @@ impl TakerSwap {

let tx_hash = transaction.tx_hash_as_bytes();
info!("Maker payment spend tx {:02x}", tx_hash);

// we should wait for only one confirmation to make sure spend maker payment transaction is not failed
let confirmations = std::cmp::min(1, self.r().data.maker_payment_confirmations);
let confirm_maker_payment_spend_input = ConfirmPaymentInput {
payment_tx: transaction.tx_hex(),
confirmations,
requires_nota: false,
wait_until: self.wait_refund_until(),
check_every: WAIT_CONFIRM_INTERVAL_SEC,
};
let wait_fut = self
.maker_coin
.wait_for_confirmations(confirm_maker_payment_spend_input);
if let Err(err) = wait_fut.compat().await {
return Ok((Some(TakerSwapCommand::Finish), vec![
TakerSwapEvent::MakerPaymentSpendFailed(
ERRL!("!wait for maker payment spend confirmations: {}", err).into(),
),
]));
}
info!("Maker payment spend confirmed");

let tx_ident = TransactionIdentifier {
tx_hex: BytesJson::from(transaction.tx_hex()),
tx_hash,
Expand Down

0 comments on commit 17a5fab

Please sign in to comment.