commit 01fc0484841fc8ced7e96798d5f4ca794b37cd41
parent 2c6a1f55fb5bef6e29415aac310f905dae522801
Author: SomberNight <somber.night@protonmail.com>
Date: Sun, 15 Dec 2019 20:12:51 +0100
CLI: properly auto-upgrade storage when needed even if storage-encrypted
previously commands would error if user had an encrypted storage that needed upgrading
Diffstat:
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/electrum/json_db.py b/electrum/json_db.py
@@ -55,12 +55,12 @@ class TxFeesValue(NamedTuple):
class JsonDB(Logger):
- def __init__(self, raw, *, manual_upgrades):
+ def __init__(self, raw, *, manual_upgrades: bool):
Logger.__init__(self)
self.lock = threading.RLock()
self.data = {}
self._modified = False
- self.manual_upgrades = manual_upgrades
+ self._manual_upgrades = manual_upgrades
self._called_after_upgrade_tasks = False
if raw: # loading existing db
self.load_data(raw)
@@ -142,12 +142,12 @@ class JsonDB(Logger):
if not isinstance(self.data, dict):
raise WalletFileException("Malformed wallet file (not dict)")
- if not self.manual_upgrades and self.requires_split():
+ if not self._manual_upgrades and self.requires_split():
raise WalletFileException("This wallet has multiple accounts and must be split")
if not self.requires_upgrade():
self._after_upgrade_tasks()
- elif not self.manual_upgrades:
+ elif not self._manual_upgrades:
self.upgrade()
def requires_split(self):
diff --git a/electrum/storage.py b/electrum/storage.py
@@ -55,11 +55,12 @@ class StorageReadWriteError(Exception): pass
class WalletStorage(Logger):
- def __init__(self, path, *, manual_upgrades=False):
+ def __init__(self, path, *, manual_upgrades: bool = False):
Logger.__init__(self)
self.lock = threading.RLock()
self.path = standardize_path(path)
self._file_exists = bool(self.path and os.path.exists(self.path))
+ self._manual_upgrades = manual_upgrades
DB_Class = JsonDB
self.logger.info(f"wallet path {self.path}")
@@ -211,7 +212,7 @@ class WalletStorage(Logger):
s = None
self.pubkey = ec_key.get_public_key_hex()
s = s.decode('utf8')
- self.db = JsonDB(s, manual_upgrades=True)
+ self.db = JsonDB(s, manual_upgrades=self._manual_upgrades)
self.load_plugins()
def encrypt_before_writing(self, plaintext: str) -> str: