wallet db: deduplicate "seed_type" field
In the db, the 'seed_type' field could be present both at the top-level and inside keystores. Note: - both fields had usages - the top-level field was added in 2.8 re "initial segwit support" (3a64ec0f2e) - there was no db upgrade for it, so older files are missing it - if present, valid values can be electrum types but also other types supported by the wizard, e.g. "bip39" - the keystore-level field was added in 4.1 (7b7bba2299) - there was a db upgrade when it was introduced, so old files also have it - if present, valid values can only be electrum types - there is not much value in the top-level one having a non-electrum value, and those values were never used by other parts of the code - note that when creating a standard wallet from a bip39 seed, the seed is discarded. Only the derived xprv and the derivation path are kept. If we changed this and also kept the seed, e.g. to display it to the user, then it would make sense to save the seed type (e.g. "bip39"). However storing that seed_type would make more sense at the keystore level (not top-level). We delete the top-level 'seed_type' field. ``` { "keystore": { "seed_type": "segwit", ... }, "seed_type": "segwit", ... } ```
This commit is contained in:
+10
-1
@@ -67,7 +67,7 @@ class WalletUnfinished(WalletFileException):
|
||||
# seed_version is now used for the version of the wallet file
|
||||
OLD_SEED_VERSION = 4 # electrum versions < 2.0
|
||||
NEW_SEED_VERSION = 11 # electrum versions >= 2.0
|
||||
FINAL_SEED_VERSION = 56 # electrum >= 2.7 will set this to prevent
|
||||
FINAL_SEED_VERSION = 57 # electrum >= 2.7 will set this to prevent
|
||||
# old versions from overwriting new format
|
||||
|
||||
|
||||
@@ -227,6 +227,7 @@ class WalletDBUpgrader(Logger):
|
||||
self._convert_version_54()
|
||||
self._convert_version_55()
|
||||
self._convert_version_56()
|
||||
self._convert_version_57()
|
||||
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure
|
||||
|
||||
def _convert_wallet_type(self):
|
||||
@@ -1096,6 +1097,14 @@ class WalletDBUpgrader(Logger):
|
||||
item['local_config'].pop('was_announced')
|
||||
self.data['seed_version'] = 56
|
||||
|
||||
def _convert_version_57(self):
|
||||
if not self._is_upgrade_method_needed(56, 56):
|
||||
return
|
||||
# The 'seed_type' field could be present both at the top-level and inside keystores.
|
||||
# We delete the one that is top-level.
|
||||
self.data.pop('seed_type', None)
|
||||
self.data['seed_version'] = 57
|
||||
|
||||
def _convert_imported(self):
|
||||
if not self._is_upgrade_method_needed(0, 13):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user