wallet_db: convert_version_74: duplicate map from lnutil for robustness
What changed, and why it matters
This commit fixes a wallet-upgrade bug, not a security vulnerability. Electrum's database upgrade code for old Lightning wallets imported a list of 'basepoints' (cryptographic key derivation points) from another file. When that other file later gained a new entry, the upgrade code broke with a KeyError and users could not open their wallets. The fix copies the exact list of basepoints needed for the upgrade directly into the upgrade function so future changes elsewhere cannot break it. There is no attacker-controlled path and no theft or code-execution risk.
No security action required. This is a robustness/availability fix. Users with old Lightning wallets should upgrade to a version containing this commit to avoid being unable to load their wallets if lnutil's basepoint map changes.
Security signals we found
No attacker-controlled input
No memory safety issue
No cryptographic weakness
No privilege escalation
Fixes a wallet-loading failure (availability issue) during DB upgrade
Evidence from the diff
The patch changes _convert_version_74 in wallet_db.py to define a local DERIVED_LOCAL_BASEPOINTS map instead of importing it from lnutil.py. The imported map later included ‘xx’: LnKeyFamily.FUNDING_ROOT_KEY, which is not present in old channel local_config dicts, causing a KeyError during wallet DB upgrade. The fix makes the conversion self-contained and robust against future additions to lnutil’s map. The change is purely defensive/robustness and prevents a denial-of-service (wallet won’t load) for users upgrading old databases.
Changed components
electrum/wallet_db.py_convert_version_74Lightning wallet database upgrade path from version 73Inspect captured patch +6 / −1
### electrum/wallet_db.py
@@ -1533,7 +1533,7 @@ def _convert_version_74(self):
and that has the same fields for LOCAL and for REMOTE.
"""
from .bip32 import BIP32Node
- from .lnutil import (DERIVED_LOCAL_BASEPOINTS, LnKeyFamily, generate_keypair,
+ from .lnutil import (LnKeyFamily, generate_keypair,
derive_payment_basepoint, get_per_commitment_point_from_seed)
if not self._is_upgrade_method_needed(73, 73):
return
@@ -1559,6 +1559,11 @@ def check(channel_id: str, name: str, derived: bytes, stored: str) -> None:
f"You must check out the '4.8.2' tag, and close+delete this channel."
)
node = BIP32Node.from_rootseed(bfh(channel_seed), xtype='standard')
+ DERIVED_LOCAL_BASEPOINTS = {
+ 'htlc_basepoint': LnKeyFamily.HTLC_BASE,
+ 'delayed_basepoint': LnKeyFamily.DELAY_BASE,
+ 'revocation_basepoint': LnKeyFamily.REVOCATION_BASE,
+ }
for name, key_family in DERIVED_LOCAL_BASEPOINTS.items():
keypair = generate_keypair(node, key_family)
check(channel_id, name, keypair.privkey, local_config[name].pop('privkey'))Why this scored 27/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.