Browse Source

wallet_db: upgrade to version 53, for imported chan backups

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

This replaces 69336befee, which was insufficient.
#8536 added a new field into the struct, which older versions do not ignore but raise:
opening a wallet file with new code updated the struct to include it,
after which old code could no longer open the wallet file.
i.e. #8536 was an invisible wallet upgrade, breaking compat.
This commit simply formalises the wallet upgrade: old code will now show
an understandable error when trying to open new files.
master
SomberNight 2 years ago
parent
commit
cee22abcb5
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/lnutil.py
  2. 12
      electrum/wallet_db.py

2
electrum/lnutil.py

@ -285,7 +285,7 @@ class ImportedChannelBackupStorage(ChannelBackupStorage):
remote_delay = attr.ib(type=int, converter=int)
remote_payment_pubkey = attr.ib(type=bytes, converter=hex_to_bytes)
remote_revocation_pubkey = attr.ib(type=bytes, converter=hex_to_bytes)
local_payment_pubkey = attr.ib(type=bytes, converter=hex_to_bytes, default=None) # type: Optional[bytes]
local_payment_pubkey = attr.ib(type=bytes, converter=hex_to_bytes) # type: Optional[bytes]
def to_bytes(self) -> bytes:
vds = BCDataStream()

12
electrum/wallet_db.py

@ -54,7 +54,7 @@ from .version import ELECTRUM_VERSION
OLD_SEED_VERSION = 4 # electrum versions < 2.0
NEW_SEED_VERSION = 11 # electrum versions >= 2.0
FINAL_SEED_VERSION = 52 # electrum >= 2.7 will set this to prevent
FINAL_SEED_VERSION = 53 # electrum >= 2.7 will set this to prevent
# old versions from overwriting new format
@ -238,6 +238,7 @@ class WalletDB(JsonDB):
self._convert_version_50()
self._convert_version_51()
self._convert_version_52()
self._convert_version_53()
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure
self._after_upgrade_tasks()
@ -1066,6 +1067,15 @@ class WalletDB(JsonDB):
raise Exception(f'unsupported wallet file: version_51 with error {error_code}')
self.data['seed_version'] = 52
def _convert_version_53(self):
if not self._is_upgrade_method_needed(52, 52):
return
cbs = self.data.get('imported_channel_backups', {})
for channel_id, cb in list(cbs.items()):
if 'local_payment_pubkey' not in cb:
cb['local_payment_pubkey'] = None
self.data['seed_version'] = 53
def _convert_imported(self):
if not self._is_upgrade_method_needed(0, 13):
return

Loading…
Cancel
Save