From 13c4d29d40a4e9a3db4966983f32d6a7623db8a2 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 5 Mar 2021 16:11:12 +1100 Subject: [PATCH] Tell the user immediately how many confirmations we expect Without this, the user doesn't see a message before the first confirmation. --- swap/src/monero/wallet.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/swap/src/monero/wallet.rs b/swap/src/monero/wallet.rs index c667d2bb..11514ff9 100644 --- a/swap/src/monero/wallet.rs +++ b/swap/src/monero/wallet.rs @@ -158,8 +158,12 @@ impl Wallet { public_view_key: PublicViewKey, transfer_proof: TransferProof, expected_amount: Amount, - expected_confirmations: u32, + conf_target: u32, ) -> Result<(), InsufficientFunds> { + let txid = &transfer_proof.tx_hash.0; + + tracing::info!(%txid, "Waiting for {} confirmation{} of Monero transaction", conf_target, if conf_target > 1 { "s" } else { "" }); + enum Error { TxNotFound, InsufficientConfirmations, @@ -196,11 +200,10 @@ impl Wallet { if proof.confirmations >= confirmations.load(Ordering::SeqCst) { confirmations.store(proof.confirmations, Ordering::SeqCst); - let txid = &transfer_proof.tx_hash.0; - info!(%txid, "Monero lock tx has {} out of {} confirmations", proof.confirmations, expected_confirmations); + info!(%txid, "Monero lock tx has {} out of {} confirmations", proof.confirmations, conf_target); } - if proof.confirmations < expected_confirmations { + if proof.confirmations < conf_target { return Err(backoff::Error::Transient(Error::InsufficientConfirmations)); }