Merge pull request #11060 from f321x/make_unsigned_tx_copy_base_tx
What changed, and why it matters
This commit fixes a bug where Electrum's wallet software would accidentally modify a transaction object supplied by the caller when creating a new unsigned transaction. The fix makes a private copy before stripping signatures, preventing unintended changes to the caller's original transaction. This is a defensive correctness fix rather than a clear-cut remote exploit, but it could prevent subtle wallet behavior bugs or UI inconsistencies.
Treat as a low-to-moderate bug fix. Review callers of `make_unsigned_transaction()` to confirm no other code paths relied on the mutation side effect. No urgent security response appears warranted absent evidence of exploitability.
Security signals we found
Mutation of caller-supplied object without documentation or copy
Signature removal on shared transaction object could affect downstream wallet state
Defensive deep-copy fix in transaction construction path
Evidence from the diff
In wallet.py::make_unsigned_transaction(), when a base_tx is provided and is not a PartialTransaction, the code calls base_tx.remove_signatures() directly on the caller-supplied object. The patch inserts base_tx = copy.deepcopy(base_tx) before remove_signatures(), ensuring the original object is not mutated. This is a side-effect bug in a wallet transaction-building helper.
Changed components
electrum/wallet.pymake_unsigned_transaction()base_tx handling for non-PartialTransaction inputsInspect captured patch +1 / −0
### electrum/wallet.py
@@ -2087,6 +2087,7 @@ def make_unsigned_transaction(
base_tx.add_info_from_wallet(self)
else:
# don't cast PartialTransaction, because it removes make_witness
+ base_tx = copy.deepcopy(base_tx) # don't mutate callers tx
base_tx.remove_signatures()
base_tx_fee = base_tx.get_fee() # FIXME could be None if some inputs are non-ismine
base_feerate = Decimal(base_tx_fee) / base_tx_sizeWhy this scored 47/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.