wallet_db upgrade: fix possible corruption of invoice amounts
see https://github.com/spesmilo/electrum/pull/7774
This commit is contained in:
@@ -52,7 +52,7 @@ if TYPE_CHECKING:
|
||||
|
||||
OLD_SEED_VERSION = 4 # electrum versions < 2.0
|
||||
NEW_SEED_VERSION = 11 # electrum versions >= 2.0
|
||||
FINAL_SEED_VERSION = 47 # electrum >= 2.7 will set this to prevent
|
||||
FINAL_SEED_VERSION = 48 # electrum >= 2.7 will set this to prevent
|
||||
# old versions from overwriting new format
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ class WalletDB(JsonDB):
|
||||
self._convert_version_45()
|
||||
self._convert_version_46()
|
||||
self._convert_version_47()
|
||||
self._convert_version_48()
|
||||
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure
|
||||
|
||||
self._after_upgrade_tasks()
|
||||
@@ -942,6 +943,16 @@ class WalletDB(JsonDB):
|
||||
del requests[key]
|
||||
self.data['seed_version'] = 47
|
||||
|
||||
def _convert_version_48(self):
|
||||
# fix possible corruption of invoice amounts, see #7774
|
||||
if not self._is_upgrade_method_needed(47, 47):
|
||||
return
|
||||
invoices = self.data.get('invoices', {})
|
||||
for key, item in list(invoices.items()):
|
||||
if item['amount_msat'] == 1000 * "!":
|
||||
item['amount_msat'] = "!"
|
||||
self.data['seed_version'] = 48
|
||||
|
||||
def _convert_imported(self):
|
||||
if not self._is_upgrade_method_needed(0, 13):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user