commit d800f88bfcdc83a2cb9d359791c0c7e8cf6fcaff
parent c9d6d11604b3a90ff1d0e1413da94ff9f96041cd
Author: SomberNight <somber.night@protonmail.com>
Date: Wed, 24 Feb 2021 18:34:17 +0100
(trivial) wallet: fix over-indentation
Diffstat:
M | electrum/wallet.py | | | 92 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
1 file changed, 46 insertions(+), 46 deletions(-)
diff --git a/electrum/wallet.py b/electrum/wallet.py
@@ -3033,56 +3033,56 @@ def restore_wallet_from_text(text, *, path, config: SimpleConfig,
return {'wallet': wallet, 'msg': msg}
-def check_password_for_directory(config, old_password, new_password=None):
- """Checks password against all wallets and returns True if they can all be updated.
- If new_password is not None, update all wallet passwords to new_password.
- """
- dirname = os.path.dirname(config.get_wallet_path())
- failed = []
- for filename in os.listdir(dirname):
- path = os.path.join(dirname, filename)
- if not os.path.isfile(path):
- continue
- basename = os.path.basename(path)
- storage = WalletStorage(path)
- if not storage.is_encrypted():
- # it is a bit wasteful load the wallet here, but that is fine
- # because we are progressively enforcing storage encryption.
- db = WalletDB(storage.read(), manual_upgrades=False)
- wallet = Wallet(db, storage, config=config)
- if wallet.has_keystore_encryption():
- try:
- wallet.check_password(old_password)
- except:
- failed.append(basename)
- continue
- if new_password:
- wallet.update_password(old_password, new_password)
- else:
- if new_password:
- wallet.update_password(None, new_password)
- continue
- if not storage.is_encrypted_with_user_pw():
- failed.append(basename)
- continue
- try:
- storage.check_password(old_password)
- except:
- failed.append(basename)
- continue
+def check_password_for_directory(config: SimpleConfig, old_password, new_password=None) -> bool:
+ """Checks password against all wallets and returns True if they can all be updated.
+ If new_password is not None, update all wallet passwords to new_password.
+ """
+ dirname = os.path.dirname(config.get_wallet_path())
+ failed = []
+ for filename in os.listdir(dirname):
+ path = os.path.join(dirname, filename)
+ if not os.path.isfile(path):
+ continue
+ basename = os.path.basename(path)
+ storage = WalletStorage(path)
+ if not storage.is_encrypted():
+ # it is a bit wasteful load the wallet here, but that is fine
+ # because we are progressively enforcing storage encryption.
db = WalletDB(storage.read(), manual_upgrades=False)
wallet = Wallet(db, storage, config=config)
- try:
- wallet.check_password(old_password)
- except:
- failed.append(basename)
- continue
- if new_password:
- wallet.update_password(old_password, new_password)
- return failed == []
+ if wallet.has_keystore_encryption():
+ try:
+ wallet.check_password(old_password)
+ except:
+ failed.append(basename)
+ continue
+ if new_password:
+ wallet.update_password(old_password, new_password)
+ else:
+ if new_password:
+ wallet.update_password(None, new_password)
+ continue
+ if not storage.is_encrypted_with_user_pw():
+ failed.append(basename)
+ continue
+ try:
+ storage.check_password(old_password)
+ except:
+ failed.append(basename)
+ continue
+ db = WalletDB(storage.read(), manual_upgrades=False)
+ wallet = Wallet(db, storage, config=config)
+ try:
+ wallet.check_password(old_password)
+ except:
+ failed.append(basename)
+ continue
+ if new_password:
+ wallet.update_password(old_password, new_password)
+ return failed == []
-def update_password_for_directory(config, old_password, new_password) -> bool:
+def update_password_for_directory(config: SimpleConfig, old_password, new_password) -> bool:
assert new_password is not None
assert check_password_for_directory(config, old_password, None)
return check_password_for_directory(config, old_password, new_password)