|
|
@ -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 = 42 # electrum >= 2.7 will set this to prevent |
|
|
|
FINAL_SEED_VERSION = 43 # electrum >= 2.7 will set this to prevent |
|
|
|
# old versions from overwriting new format |
|
|
|
|
|
|
|
|
|
|
@ -191,6 +191,7 @@ class WalletDB(JsonDB): |
|
|
|
self._convert_version_40() |
|
|
|
self._convert_version_41() |
|
|
|
self._convert_version_42() |
|
|
|
self._convert_version_43() |
|
|
|
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure |
|
|
|
|
|
|
|
self._after_upgrade_tasks() |
|
|
@ -837,6 +838,18 @@ class WalletDB(JsonDB): |
|
|
|
for _type, addr, val in item['outputs']] |
|
|
|
self.data['seed_version'] = 42 |
|
|
|
|
|
|
|
def _convert_version_43(self): |
|
|
|
if not self._is_upgrade_method_needed(42, 42): |
|
|
|
return |
|
|
|
channels = self.data.pop('channels', {}) |
|
|
|
for k, c in channels.items(): |
|
|
|
log = c['log'] |
|
|
|
c['fail_htlc_reasons'] = log.pop('fail_htlc_reasons', {}) |
|
|
|
c['unfulfilled_htlcs'] = log.pop('unfulfilled_htlcs', {}) |
|
|
|
log["1"]['unacked_updates'] = log.pop('unacked_local_updates2', {}) |
|
|
|
self.data['channels'] = channels |
|
|
|
self.data['seed_version'] = 43 |
|
|
|
|
|
|
|
def _convert_imported(self): |
|
|
|
if not self._is_upgrade_method_needed(0, 13): |
|
|
|
return |
|
|
@ -1344,6 +1357,14 @@ class WalletDB(JsonDB): |
|
|
|
v = dict((k, ShachainElement(bfh(x[0]), int(x[1]))) for k, x in v.items()) |
|
|
|
elif key == 'data_loss_protect_remote_pcp': |
|
|
|
v = dict((k, bfh(x)) for k, x in v.items()) |
|
|
|
# convert htlc_id keys to int |
|
|
|
if key in ['adds', 'locked_in', 'settles', 'fails', 'fee_updates', 'buckets']: |
|
|
|
v = dict((int(k), x) for k, x in v.items()) |
|
|
|
# convert keys to HTLCOwner |
|
|
|
if key == 'log' or (path and path[-1] in ['locked_in', 'fails', 'settles']): |
|
|
|
if "1" in v: |
|
|
|
v[LOCAL] = v.pop("1") |
|
|
|
v[REMOTE] = v.pop("-1") |
|
|
|
return v |
|
|
|
|
|
|
|
def _convert_value(self, path, key, v): |
|
|
|