wallet: fix channels backups in .backup files
This is a regression from 64a931f21e,
which introduced "onchain_channel_backups", and renamed
the old "channel_backups" key to "imported_channel_backups".
The `save_backup` method was not changed to use the new "imported_channel_backups" key,
so the channel backups are in the backup file but they are ignored.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user