diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 1ef89f9ce..82a81e7f0 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -212,7 +212,8 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { }; std::vector groups; std::vector 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)));