From a7b15e40a0806ff5792ece34c184d4f988f913f7 Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 1 Dec 2026 15:11:48 -0600 Subject: [PATCH] wallet: say why a zsweep or autoshield round failed when its tx is rejected When CommitAutomatedTx refused a transaction (AcceptToMemoryPool rejected it), the sweep and autoshield ops returned false without setting an error, so the operation finished as "failed" with an empty message: Sweep operation finished. (status=failed, error=) Seen twice in 175 sweep rounds in the 2026-12-01 soak; one was a note already spent by another transaction ("sapling nullifier ... exists"). Both ops now set RPC_WALLET_ERROR and a message naming the rejected txid, pointing at debug.log for the mempool's reason (CommitTransaction does not return it), and saying the next round retries. Consolidation already records a per-address reason. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp | 3 +++ src/wallet/asyncrpcoperation_sweep.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp b/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp index 72cf166b6..9628269ed 100644 --- a/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp @@ -461,6 +461,9 @@ bool AsyncRPCOperation_autoshieldcoinbase::main_impl() { } LogPrintf("%s: autoshield tx FAILED in CommitTransaction, txid=%s\n", opid, tx.GetHash().ToString()); + set_error_code(RPC_WALLET_ERROR); + set_error_message(strprintf("Autoshield transaction %s was not accepted into the mempool (see debug.log for the " + "reason). The next round tries again.", tx.GetHash().ToString())); return false; } diff --git a/src/wallet/asyncrpcoperation_sweep.cpp b/src/wallet/asyncrpcoperation_sweep.cpp index fcc4ccad1..e86f3d457 100644 --- a/src/wallet/asyncrpcoperation_sweep.cpp +++ b/src/wallet/asyncrpcoperation_sweep.cpp @@ -411,6 +411,12 @@ bool AsyncRPCOperation_sweep::main_impl() { numTxCreated++; } else { LogPrintf("%s: Sweep transaction FAILED in CommitTransaction, txid=%s\n",opid , tx.GetHash().ToString()); + // Say why the round failed: this used to finish as "failed" with an empty error. The mempool's + // reason is in debug.log just above (most often a note already spent by another transaction). + set_error_code(RPC_WALLET_ERROR); + set_error_message(strprintf("Sweep transaction %s was not accepted into the mempool (see debug.log for " + "the reason; usually one of its notes was spent by another transaction " + "meanwhile). The next round sweeps what is left.", tx.GetHash().ToString())); setSweepResult(numTxCreated, amountSwept, sweepTxIds); status = false; break;