(trivial) wallet: fix over-indentation
This commit is contained in:
@@ -3033,56 +3033,56 @@ def restore_wallet_from_text(text, *, path, config: SimpleConfig,
|
|||||||
return {'wallet': wallet, 'msg': msg}
|
return {'wallet': wallet, 'msg': msg}
|
||||||
|
|
||||||
|
|
||||||
def check_password_for_directory(config, old_password, new_password=None):
|
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.
|
"""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.
|
If new_password is not None, update all wallet passwords to new_password.
|
||||||
"""
|
"""
|
||||||
dirname = os.path.dirname(config.get_wallet_path())
|
dirname = os.path.dirname(config.get_wallet_path())
|
||||||
failed = []
|
failed = []
|
||||||
for filename in os.listdir(dirname):
|
for filename in os.listdir(dirname):
|
||||||
path = os.path.join(dirname, filename)
|
path = os.path.join(dirname, filename)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
continue
|
continue
|
||||||
basename = os.path.basename(path)
|
basename = os.path.basename(path)
|
||||||
storage = WalletStorage(path)
|
storage = WalletStorage(path)
|
||||||
if not storage.is_encrypted():
|
if not storage.is_encrypted():
|
||||||
# it is a bit wasteful load the wallet here, but that is fine
|
# it is a bit wasteful load the wallet here, but that is fine
|
||||||
# because we are progressively enforcing storage encryption.
|
# 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
|
|
||||||
db = WalletDB(storage.read(), manual_upgrades=False)
|
db = WalletDB(storage.read(), manual_upgrades=False)
|
||||||
wallet = Wallet(db, storage, config=config)
|
wallet = Wallet(db, storage, config=config)
|
||||||
try:
|
if wallet.has_keystore_encryption():
|
||||||
wallet.check_password(old_password)
|
try:
|
||||||
except:
|
wallet.check_password(old_password)
|
||||||
failed.append(basename)
|
except:
|
||||||
continue
|
failed.append(basename)
|
||||||
if new_password:
|
continue
|
||||||
wallet.update_password(old_password, new_password)
|
if new_password:
|
||||||
return failed == []
|
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 new_password is not None
|
||||||
assert check_password_for_directory(config, old_password, None)
|
assert check_password_for_directory(config, old_password, None)
|
||||||
return check_password_for_directory(config, old_password, new_password)
|
return check_password_for_directory(config, old_password, new_password)
|
||||||
|
|||||||
Reference in New Issue
Block a user