From 180035296e749335727ac86a477f33b6f108af48 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Fri, 18 Oct 2019 12:40:57 -0400 Subject: [PATCH] support unlocking with blank password but throw an error when encrypting with blank password --- torba/torba/client/wallet.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/torba/torba/client/wallet.py b/torba/torba/client/wallet.py index 3f85d88a0..d546cd33f 100644 --- a/torba/torba/client/wallet.py +++ b/torba/torba/client/wallet.py @@ -206,11 +206,17 @@ class Wallet: return False def unlock(self, password): - self.encryption_password = password for account in self.accounts: if account.encrypted: if not account.decrypt(password): return False + if password == "": + # for backwards compatiblity: + # some accounts were encrypted with blank password, this allows + # those accounts to be unlocked but then not encrypted anymore + self.decrypt() + else: + self.encryption_password = password return True def lock(self): @@ -232,6 +238,8 @@ class Wallet: def encrypt(self, password): assert not self.is_locked, "Cannot re-encrypt a locked wallet, unlock first." + if not password: + raise ValueError("Cannot encrypt with blank password.") self.encryption_password = password self.preferences[ENCRYPT_ON_DISK] = True self.save()