1
0

db upgrade: store channel tx height and timestamps in 'channels'

This commit is contained in:
ThomasV
2020-02-22 18:26:52 +01:00
parent e8ee4250d9
commit 20d8da7e24
5 changed files with 40 additions and 21 deletions

View File

@@ -50,7 +50,7 @@ if TYPE_CHECKING:
OLD_SEED_VERSION = 4 # electrum versions < 2.0
NEW_SEED_VERSION = 11 # electrum versions >= 2.0
FINAL_SEED_VERSION = 25 # electrum >= 2.7 will set this to prevent
FINAL_SEED_VERSION = 26 # electrum >= 2.7 will set this to prevent
# old versions from overwriting new format
@@ -171,6 +171,7 @@ class WalletDB(JsonDB):
self._convert_version_23()
self._convert_version_24()
self._convert_version_25()
self._convert_version_26()
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure
self._after_upgrade_tasks()
@@ -571,6 +572,21 @@ class WalletDB(JsonDB):
}
self.data['seed_version'] = 25
def _convert_version_26(self):
if not self._is_upgrade_method_needed(25, 25):
return
channels = self.data.get('channels', {})
channel_timestamps = self.data.pop('lightning_channel_timestamps', {})
for channel_id, c in channels.items():
item = channel_timestamps.get(channel_id)
if item:
funding_txid, funding_height, funding_timestamp, closing_txid, closing_height, closing_timestamp = item
if funding_txid:
c['funding_height'] = funding_txid, funding_height, funding_timestamp
if closing_txid:
c['closing_height'] = closing_txid, closing_height, closing_timestamp
self.data['seed_version'] = 26
def _convert_imported(self):
if not self._is_upgrade_method_needed(0, 13):
return