From 03df14b27a657b9c6b89e0dc311e89ae03b5d5fd Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 25 Feb 2022 20:44:05 +0100 Subject: [PATCH] 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 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' ``` --- electrum/wallet_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py index cdd1fe969..152b642a9 100644 --- a/electrum/wallet_db.py +++ b/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