wallet: keep a throwing consolidation round's committed txs in its record

The op tallied the round in a local and handed it over only through
setConsolidationResult, which an exception thrown mid-round skips, so
last_round and the cumulative totals lost transactions it had already
committed. Tally into the member main() records from instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 11:36:59 -05:00
co-authored by Claude Opus 5.5
parent 7983a3dc68
commit 63e7d6ef2d
@@ -212,7 +212,8 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
};
std::vector<AddressNotes> groups;
std::vector<PlannedTx> txs;
ConsolidationTally tally;
// The member, not a local: if anything below throws, main() still records what was committed.
ConsolidationTally& tally = tally_;
{
LOCK2(cs_main, pwalletMain->cs_wallet);
// We set minDepth to 11 to avoid unconfirmed notes and in anticipation of specifying
@@ -429,7 +430,8 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
}
void AsyncRPCOperation_saplingconsolidation::setConsolidationResult(const ConsolidationTally& tally) {
tally_ = tally;
if (&tally != &tally_)
tally_ = tally;
UniValue res(UniValue::VOBJ);
res.push_back(Pair("num_tx_created", (int)tally.txids.size()));
res.push_back(Pair("amount_consolidated", FormatMoney(tally.amountConsolidated)));