AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 27 Bitcoin

wallet_db: convert_version_74: duplicate map from lnutil for robustness

Public commit record

What the developer wrote

Authored by SomberNight

73/100 · Adequate
wallet_db: convert_version_74: duplicate map from lnutil for robustness

Previously we assumed `DERIVED_LOCAL_BASEPOINTS` would never change in future code.

```diff
diff --git a/electrum/lnutil.py b/electrum/lnutil.py
index efded00e80..b0b400d965 100644
--- a/electrum/lnutil.py
+++ b/electrum/lnutil.py
@@ -2131,6 +2133,7 @@ DERIVED_LOCAL_BASEPOINTS = {
'htlc_basepoint': LnKeyFamily.HTLC_BASE,
'delayed_basepoint': LnKeyFamily.DELAY_BASE,
'revocation_basepoint': LnKeyFamily.REVOCATION_BASE,
+ 'xx': LnKeyFamily.FUNDING_ROOT_KEY,
}

```

```
Traceback (most recent call last):
File "/home/user/wspace/electrum/electrum/gui/qt/__init__.py", line 441, in start_new_window
wallet = self._start_wizard_to_select_or_create_wallet(path)
File "/home/user/wspace/electrum/electrum/gui/qt/__init__.py", line 513, in _start_wizard_to_select_or_create_wallet
wallet = self.daemon.load_wallet(wallet_file, password, upgrade=True)
File "/home/user/wspace/electrum/electrum/daemon.py", line 496, in func_wrapper
return func(self, *args, **kwargs)
File "/home/user/wspace/electrum/electrum/daemon.py", line 522, in load_wallet
wallet = self._load_wallet(
path, password, upgrade=upgrade, config=self.config, force_check_password=force_check_password)
File "/home/user/wspace/electrum/electrum/util.py", line 518, in do_profile
o = func(*args, **kw_args)
File "/home/user/wspace/electrum/electrum/daemon.py", line 556, in _load_wallet
db = WalletDB(storage.read(), storage=storage, upgrade=upgrade)
File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1714, in __init__
JsonDB.__init__(
~~~~~~~~~~~~~~~^
self,
^^^^^
...<3 lines>...
upgrader=partial(upgrade_wallet_db, do_upgrade=upgrade),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/user/wspace/electrum/electrum/json_db.py", line 107, in __init__
data, was_upgraded = upgrader(data)
~~~~~~~~^^^^^^
File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1698, in upgrade_wallet_db
dbu.upgrade()
~~~~~~~~~~~^^
File "/home/user/wspace/electrum/electrum/util.py", line 518, in do_profile
o = func(*args, **kw_args)
File "/home/user/wspace/electrum/electrum/wallet_db.py", line 266, in upgrade
self._convert_version_74()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1548, in _convert_version_74
check(channel_id, name, keypair.privkey, local_config[name].pop('privkey'))
~~~~~~~~~~~~^^^^^^
KeyError: 'xx'
```
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

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.

Recommended action

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

01

No attacker-controlled input

02

No memory safety issue

03

No cryptographic weakness

04

No privilege escalation

05

Fixes a wallet-loading failure (availability issue) during DB upgrade

Risk score

Why this scored 27/100

Our methodology →
Potential impact 8/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.