wallet_db: convert_version_74: handle old chans lacking channel_seed
What changed, and why it matters
This commit fixes a wallet-upgrade crash. Very old Electrum Lightning channels created from pre-release code before April 2020 did not store a 'channel_seed'. The upgrade code assumed the field always existed and would crash when it was missing. The patch detects the missing field and shows a clear error message telling the user how to recover, instead of crashing silently or with a confusing error.
No immediate security action required. Users with such ancient pre-release channels should follow the error message guidance (use Electrum 4.8.2 to close and delete the channel) before upgrading.
Security signals we found
defensive input validation added
missing required field now handled explicitly
user-facing error message added for unrecoverable state
no cryptographic or network security boundary crossed
Evidence from the diff
In wallet_db.py, convert_version_74() migrates Lightning channel data by deriving basepoints from a stored channel_seed. The original code used dict.pop(‘channel_seed’), which raises KeyError if absent. The change uses pop(‘channel_seed’, None) and raises a WalletFileException with a specific recovery instruction (checkout 4.8.2, close+delete the channel) when the seed is missing. This is a data-migration robustness fix, not a cryptographic or network vulnerability.
Changed components
electrum/wallet_db.pyLightning channel wallet upgrade path (convert_version_74)Inspect captured patch +7 / −1
### electrum/wallet_db.py
@@ -1541,7 +1541,13 @@ def check(channel_id: str, name: str, derived: bytes, stored: str) -> None:
for channel_id, c in self.data.get('channels', {}).items():
local_config = c['local_config']
remote_config = c['remote_config']
- channel_seed = local_config.pop('channel_seed')
+ channel_seed = local_config.pop('channel_seed', None)
+ if channel_seed is None:
+ raise WalletFileException(
+ f"Cannot upgrade this wallet: it contains a LN channel ({channel_id}) that lacks a channel_seed. "
+ f"This can only happen for channels created from unreleased development git commits (before 2020 April, before 4.0). "
+ f"You must check out the '4.8.2' tag, and close+delete this channel."
+ )
node = BIP32Node.from_rootseed(bfh(channel_seed), xtype='standard')
for name, key_family in DERIVED_LOCAL_BASEPOINTS.items():
keypair = generate_keypair(node, key_family)Why this scored 20/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.