From 7b8e257ebb2cb023de6a9344fd5821aec9487409 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 15 Aug 2022 16:03:21 +0000 Subject: [PATCH] wallet db upgrade: rm support of "legacy" lightning channels ("legacy" as in pre-static-remote-key channels) --- electrum/wallet_db.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py index 9fae80a5a..f861f9dee 100644 --- a/electrum/wallet_db.py +++ b/electrum/wallet_db.py @@ -52,7 +52,7 @@ if TYPE_CHECKING: OLD_SEED_VERSION = 4 # electrum versions < 2.0 NEW_SEED_VERSION = 11 # electrum versions >= 2.0 -FINAL_SEED_VERSION = 48 # electrum >= 2.7 will set this to prevent +FINAL_SEED_VERSION = 49 # electrum >= 2.7 will set this to prevent # old versions from overwriting new format @@ -197,6 +197,7 @@ class WalletDB(JsonDB): self._convert_version_46() self._convert_version_47() self._convert_version_48() + self._convert_version_49() self.put('seed_version', FINAL_SEED_VERSION) # just to be sure self._after_upgrade_tasks() @@ -953,6 +954,22 @@ class WalletDB(JsonDB): item['amount_msat'] = "!" self.data['seed_version'] = 48 + def _convert_version_49(self): + if not self._is_upgrade_method_needed(48, 48): + return + channels = self.data.get('channels', {}) + legacy_chans = [chan_dict for chan_dict in channels.values() + if chan_dict['channel_type'] == ChannelType.OPTION_LEGACY_CHANNEL] + if legacy_chans: + raise WalletFileException( + f"This wallet contains {len(legacy_chans)} lightning channels of type 'LEGACY'. " + f"These channels were created using unreleased development versions of Electrum " + f"before the first lightning-capable release of 4.0, and are not supported anymore. " + f"Please use Electrum 4.3.0 to open this wallet, close the channels, " + f"and delete them from the wallet." + ) + self.data['seed_version'] = 49 + def _convert_imported(self): if not self._is_upgrade_method_needed(0, 13): return