wallet: don't remove ln xprv from wallet backup
What changed, and why it matters
This commit fixes a bug in Electrum's wallet backup feature. Previously, when creating a backup, the software incorrectly wiped a private Lightning key ('lightning_privkey2') from non-deterministic Lightning wallets. That meant backups could be incomplete and users might not be able to recover their Lightning funds from the backup. The fix simply stops removing that key during backup.
Users relying on non-deterministic Lightning wallets should update Electrum and create fresh wallet backups after patching, since previous backups may be missing the lightning_privkey2 key and could be incomplete.
Security signals we found
Loss/corruption of cryptographic backup material
Private key handling in backup path
Fixes previously reported issue (#7513)
Non-deterministic key backup gap
Evidence from the diff
In electrum/wallet.py’s save_backup(), a line that set ‘lightning_privkey2’ to None in the backup database was removed. The commit message states this fixes the same issue as GitHub issue #7513, but for non-deterministic Lightning wallets. The change ensures the Lightning private key is preserved in wallet backups, restoring recoverability of Lightning funds for affected wallet types.
Changed components
electrum/wallet.pysave_backup()Lightning non-deterministic walletsInspect 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 64/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.