Browse Source

wallet_db: handle legacy channels in convert_version_44

I still have a mainnet wallet with some pre-static-remotekey channels
(though those channels are closed) that I do not want to delete yet.

follow-up https://github.com/spesmilo/electrum/pull/7636

```
E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\__init__.py", line 307, in wrapper
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\gui\qt\__init__.py", line 332, in start_new_window
    wallet = self._start_wizard_to_select_or_create_wallet(path)
  File "...\electrum\electrum\gui\qt\__init__.py", line 377, in _start_wizard_to_select_or_create_wallet
    db = WalletDB(storage.read(), manual_upgrades=False)
  File "...\electrum\electrum\wallet_db.py", line 73, in __init__
    self.load_data(raw)
  File "...\electrum\electrum\wallet_db.py", line 106, in load_data
    self.upgrade()
  File "...\electrum\electrum\util.py", line 439, in <lambda>
    return lambda *args, **kw_args: do_profile(args, kw_args)
  File "...\electrum\electrum\util.py", line 435, in do_profile
    o = func(*args, **kw_args)
  File "...\electrum\electrum\wallet_db.py", line 195, in upgrade
    self._convert_version_44()
  File "...\electrum\electrum\wallet_db.py", line 859, in _convert_version_44
    if item['static_remotekey_enabled']:
KeyError: 'static_remotekey_enabled'
```
patch-4
SomberNight 3 years ago
parent
commit
03df14b27a
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/wallet_db.py

4
electrum/wallet_db.py

@ -856,11 +856,11 @@ class WalletDB(JsonDB):
return
channels = self.data.get('channels', {})
for key, item in channels.items():
if item['static_remotekey_enabled']:
if bool(item.get('static_remotekey_enabled')):
channel_type = ChannelType.OPTION_STATIC_REMOTEKEY
else:
channel_type = ChannelType(0)
del item['static_remotekey_enabled']
item.pop('static_remotekey_enabled', None)
item['channel_type'] = channel_type
self.data['seed_version'] = 44

Loading…
Cancel
Save