forked from LBRYCommunity/lbry-sdk
dont error if blank password was set previously
This commit is contained in:
parent
21d291531e
commit
a7f8febed7
1 changed files with 3 additions and 9 deletions
|
@ -142,7 +142,7 @@ class Wallet:
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
if self.preferences.get(ENCRYPT_ON_DISK, False):
|
if self.preferences.get(ENCRYPT_ON_DISK, False):
|
||||||
if self.encryption_password:
|
if self.encryption_password is not None:
|
||||||
return self.storage.write(self.to_dict(encrypt_password=self.encryption_password))
|
return self.storage.write(self.to_dict(encrypt_password=self.encryption_password))
|
||||||
elif not self.is_locked:
|
elif not self.is_locked:
|
||||||
log.warning(
|
log.warning(
|
||||||
|
@ -155,7 +155,7 @@ class Wallet:
|
||||||
def hash(self) -> bytes:
|
def hash(self) -> bytes:
|
||||||
h = sha256()
|
h = sha256()
|
||||||
if self.preferences.get(ENCRYPT_ON_DISK, False):
|
if self.preferences.get(ENCRYPT_ON_DISK, False):
|
||||||
assert self.encryption_password, \
|
assert self.encryption_password is not None, \
|
||||||
"Encryption is enabled but no password is available, cannot generate hash."
|
"Encryption is enabled but no password is available, cannot generate hash."
|
||||||
h.update(self.encryption_password.encode())
|
h.update(self.encryption_password.encode())
|
||||||
h.update(self.preferences.hash)
|
h.update(self.preferences.hash)
|
||||||
|
@ -209,13 +209,7 @@ class Wallet:
|
||||||
if account.encrypted:
|
if account.encrypted:
|
||||||
if not account.decrypt(password):
|
if not account.decrypt(password):
|
||||||
return False
|
return False
|
||||||
if password == "":
|
self.encryption_password = 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
|
return True
|
||||||
|
|
||||||
def lock(self):
|
def lock(self):
|
||||||
|
|
Loading…
Reference in a new issue