From db86aeb83af233fc79c61a2f97b38cca29e2cf67 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Tue, 18 Jan 2022 14:54:43 +0100 Subject: [PATCH] wallet: replace static remotekey with channel type --- electrum/wallet_db.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py index 8f4c4248e..cdd1fe969 100644 --- a/electrum/wallet_db.py +++ b/electrum/wallet_db.py @@ -37,7 +37,7 @@ from .invoices import Invoice from .keystore import bip44_derivation from .transaction import Transaction, TxOutpoint, tx_from_any, PartialTransaction, PartialTxOutput from .logging import Logger -from .lnutil import LOCAL, REMOTE, FeeUpdate, UpdateAddHtlc, LocalConfig, RemoteConfig, Keypair, OnlyPubkeyKeypair, RevocationStore +from .lnutil import LOCAL, REMOTE, FeeUpdate, UpdateAddHtlc, LocalConfig, RemoteConfig, ChannelType from .lnutil import ImportedChannelBackupStorage, OnchainChannelBackupStorage from .lnutil import ChannelConstraints, Outpoint, ShachainElement from .json_db import StoredDict, JsonDB, locked, modifier @@ -53,7 +53,7 @@ if TYPE_CHECKING: OLD_SEED_VERSION = 4 # electrum versions < 2.0 NEW_SEED_VERSION = 11 # electrum versions >= 2.0 -FINAL_SEED_VERSION = 43 # electrum >= 2.7 will set this to prevent +FINAL_SEED_VERSION = 44 # electrum >= 2.7 will set this to prevent # old versions from overwriting new format @@ -192,6 +192,7 @@ class WalletDB(JsonDB): self._convert_version_41() self._convert_version_42() self._convert_version_43() + self._convert_version_44() self.put('seed_version', FINAL_SEED_VERSION) # just to be sure self._after_upgrade_tasks() @@ -850,6 +851,19 @@ class WalletDB(JsonDB): self.data['channels'] = channels self.data['seed_version'] = 43 + def _convert_version_44(self): + if not self._is_upgrade_method_needed(43, 43): + return + channels = self.data.get('channels', {}) + for key, item in channels.items(): + if item['static_remotekey_enabled']: + channel_type = ChannelType.OPTION_STATIC_REMOTEKEY + else: + channel_type = ChannelType(0) + del item['static_remotekey_enabled'] + item['channel_type'] = channel_type + self.data['seed_version'] = 44 + def _convert_imported(self): if not self._is_upgrade_method_needed(0, 13): return