What changed, and why it matters
This commit fixes a crash in Electrum's transaction builder. If a user had only one on-chain coin (UTXO) that was just enough to meet a reserve requirement, clicking 'Max' in the send tab would hit an internal assertion and fail instead of showing a proper 'not enough funds' error. The fix adds a check that raises a normal NotEnoughFunds exception before the code reaches the assertion.
No immediate security response needed beyond applying the fix. This is a robustness improvement that prevents a user-triggered crash. Consider reviewing other assertion points in transaction construction for similar reachable failures.
Security signals we found
Denial-of-service-like crash path triggered by user action in normal wallet state
Assertion failure reachable through GUI send flow
Fix converts assertion crash into handled NotEnoughFunds exception
Evidence from the diff
In wallet.py’s make_unsigned_tx, when building a ‘Max’ (sweep) transaction, the code could end up with an empty tx_inputs list. It then called PartialTransaction.from_io with zero inputs and later asserted len(tx.inputs()) > 0. The patch adds an explicit guard: if not tx_inputs: raise NotEnoughFunds(). This converts a programming assertion failure into a handled, user-facing exception for an unspendable wallet state.
Changed components
electrum/wallet.pymake_unsigned_txGUI send tab Max buttonInspect captured patch +2 / −0
### electrum/wallet.py
@@ -2220,6 +2220,8 @@ def distribute_amount(amount):
fee = fee_estimator(tx.estimated_size())
distribute_amount(to_distribute - fee)
+ if not tx_inputs:
+ raise NotEnoughFunds()
tx = PartialTransaction.from_io(list(tx_inputs), list(outputs))
assert len(tx.inputs()) > 0, "any bitcoin tx must have at least 1 input by consensus"Why this scored 29/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.