Merge pull request #10851 from f321x/fix_7513_non_deterministic_wallet
What changed, and why it matters
This change fixes a bug in Electrum wallet backups. Previously, when creating a backup of a wallet that had Lightning (Bitcoin's layer-2 network) enabled, the backup code was incorrectly wiping out the Lightning private key from the backup copy. A backup without this key cannot fully restore the wallet's Lightning funds and state. The fix simply stops removing that key, so backups remain complete and recoverable.
Users who created backups of Lightning-enabled wallets with affected Electrum versions should verify whether their backups contain the lightning_privkey2 value and, if missing, consider creating a fresh backup after updating. Developers should review whether any other backup paths strip Lightning keys.
Security signals we found
Loss of recoverability / backup integrity
Private key handling change
Lightning wallet backup completeness
Evidence from the diff
In electrum/wallet.py’s save_backup(), the code iterates over Lightning channels, converts them to channel_backups, then clears the ‘channels’ stored data. It was also clearing ‘lightning_privkey2’ (the Lightning xprv / node key). Removing this private key from the backup makes the backup non-deterministic with respect to Lightning: the on-chain seed can still restore on-chain funds, but Lightning channel states and the node’s key derivation cannot be recovered from seed alone. The patch removes the line that nulls lightning_privkey2, preserving it in the backup database.
Changed components
electrum/wallet.pyWallet backup functionalityLightning (lnworker) key storageInspect captured patch +0 / −1
### electrum/wallet.py
@@ -513,7 +513,6 @@ def save_backup(self, backup_dir):
for chan_id, chan in self.lnworker.channels.items():
channel_backups[chan_id.hex()] = self.lnworker.create_channel_backup(chan_id)
new_db.put('channels', None)
- new_db.put('lightning_privkey2', None)
new_db.set_modified(True)
new_db.write()
return new_pathWhy this scored 56/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.