What changed, and why it matters
This patch fixes a bug in the Monero wallet where, if a pending transaction failed, the wallet could incorrectly mark coins as unspent even though they had already been spent by a separate confirmed transaction. This could let the wallet try to spend the same coins again, leading to failed transactions, confusion, or in the worst case creation of a double-spend attempt that the network would reject. The fix tells the wallet to leave the 'spent' flag alone when a failure occurs if the coins were already spent by a confirmed transaction.
Apply the patch. Users who had pending transactions fail while the same inputs were spent by confirmed transactions should rescan their wallet or refresh to ensure spent-status and balance are consistent. Monitor for any related reports of balance discrepancies or failed spends.
Security signals we found
Incorrect state reset on failure path
Potential double-spend attempt caused by stale UTXO selection
Wallet balance/availability inconsistency after failed pending tx
Evidence from the diff
In wallet2::process_unconfirmed_transfer(), when processing a transaction that failed to be confirmed, the code iterates over inputs and resets their spent status. The bug was that it did not check whether an output had already been spent by a confirmed transaction (m_spent_height > 0). The added guard if (!spent && td.m_spent_height > 0) continue; prevents the wallet from clearing the spent flag on outputs whose spending is already recorded on-chain. This avoids marking already-spent outputs as available for new transactions.
Changed components
src/wallet/wallet2.cppwallet2::process_unconfirmed_transfer()Inspect captured patch +2 / −0
### src/wallet/wallet2.cpp
@@ -3854,6 +3854,8 @@ void wallet2::process_unconfirmed_transfer(bool incremental, const crypto::hash
continue;
if (td.m_spent == spent)
continue;
+ if (!spent && td.m_spent_height > 0)
+ continue; // spent by a confirmed tx, which this tx failing does not release
LOG_PRINT_L1("Resetting spent status for output " << vini << ": " << key_image << " (spent=" << spent << ")");
if (spent)Why this scored 57/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.