Tell the user immediately how many confirmations we expect

Without this, the user doesn't see a message before the first
confirmation.
This commit is contained in:
Thomas Eizinger 2021-03-05 16:11:12 +11:00
parent 4883e23dd8
commit 13c4d29d40
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -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));
}