Browse Source

Merge pull request #7341 from SomberNight/202106_issue7339

wallet: fix channels backups in .backup files
patch-4
ThomasV 4 years ago
committed by GitHub
parent
commit
0f4f5e5fb7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      electrum/wallet.py
  2. 12
      electrum/wallet_db.py

2
electrum/wallet.py

@ -318,7 +318,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
new_db = WalletDB(self.db.dump(), manual_upgrades=False)
if self.lnworker:
channel_backups = new_db.get_dict('channel_backups')
channel_backups = new_db.get_dict('imported_channel_backups')
for chan_id, chan in self.lnworker.channels.items():
channel_backups[chan_id.hex()] = self.lnworker.create_channel_backup(chan_id)
new_db.put('channels', None)

12
electrum/wallet_db.py

@ -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 = 40 # electrum >= 2.7 will set this to prevent
FINAL_SEED_VERSION = 41 # electrum >= 2.7 will set this to prevent
# old versions from overwriting new format
@ -189,6 +189,7 @@ class WalletDB(JsonDB):
self._convert_version_38()
self._convert_version_39()
self._convert_version_40()
self._convert_version_41()
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure
self._after_upgrade_tasks()
@ -811,6 +812,15 @@ class WalletDB(JsonDB):
ks['seed_type'] = seed_type
self.data['seed_version'] = 40
def _convert_version_41(self):
# this is a repeat of upgrade 39, to fix wallet backup files (see #7339)
if not self._is_upgrade_method_needed(40, 40):
return
imported_channel_backups = self.data.pop('channel_backups', {})
imported_channel_backups.update(self.data.get('imported_channel_backups', {}))
self.data['imported_channel_backups'] = imported_channel_backups
self.data['seed_version'] = 41
def _convert_imported(self):
if not self._is_upgrade_method_needed(0, 13):
return

Loading…
Cancel
Save