From ec433f069fdb4716b37732b0e0f5a212676dbf16 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Tue, 13 Sep 2022 07:12:02 -0500 Subject: [PATCH] Substitute InvalidPasswordError for zlib.error. --- lbry/wallet/wallet.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/wallet.py b/lbry/wallet/wallet.py index e43e4871f..abbfb688c 100644 --- a/lbry/wallet/wallet.py +++ b/lbry/wallet/wallet.py @@ -10,6 +10,7 @@ from collections import UserDict from hashlib import sha256 from operator import attrgetter from lbry.crypto.crypt import better_aes_encrypt, better_aes_decrypt +from lbry.error import InvalidPasswordError from .account import Account if typing.TYPE_CHECKING: @@ -171,7 +172,12 @@ class Wallet: @classmethod def unpack(cls, password, encrypted): decrypted = better_aes_decrypt(password, encrypted) - decompressed = zlib.decompress(decrypted) + try: + decompressed = zlib.decompress(decrypted) + except zlib.error as e: + if "incorrect header check" in e.args[0].lower(): + raise InvalidPasswordError() + raise return json.loads(decompressed) def merge(self, manager: 'WalletManager',