forked from LBRYCommunity/lbry-sdk
add InvalidPasswordError handling to more places
This commit is contained in:
parent
75d78bfa53
commit
94a41270d0
4 changed files with 5 additions and 12 deletions
|
@ -1,2 +1,2 @@
|
|||
class BaseError(Exception):
|
||||
log_level = 50
|
||||
pass
|
||||
|
|
|
@ -599,14 +599,6 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
except asyncio.CancelledError:
|
||||
log.info("cancelled API call for: %s", function_name)
|
||||
raise
|
||||
except BaseError as e:
|
||||
if log.isEnabledFor(e.log_level):
|
||||
log.exception("SDK generated the following exception:")
|
||||
return JSONRPCError(
|
||||
f"Error calling {function_name} with args {args}\n" + str(e),
|
||||
JSONRPCError.CODE_APPLICATION_ERROR,
|
||||
format_exc()
|
||||
)
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
log.exception("error handling api request")
|
||||
return JSONRPCError(
|
||||
|
|
|
@ -2,9 +2,9 @@ import asyncio
|
|||
import json
|
||||
|
||||
from torba.client.wallet import ENCRYPT_ON_DISK
|
||||
from torba.client.errors import InvalidPasswordError
|
||||
from lbry.testcase import CommandTestCase
|
||||
from lbry.wallet.dewies import dict_values_to_lbc
|
||||
from lbry.error import InvalidPasswordError
|
||||
|
||||
|
||||
class WalletCommands(CommandTestCase):
|
||||
|
|
|
@ -10,6 +10,7 @@ from torba.client.mnemonic import Mnemonic
|
|||
from torba.client.bip32 import PrivateKey, PubKey, from_extended_key_string
|
||||
from torba.client.hash import aes_encrypt, aes_decrypt, sha256
|
||||
from torba.client.constants import COIN
|
||||
from torba.client.errors import InvalidPasswordError
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from torba.client import baseledger, wallet as basewallet
|
||||
|
@ -349,11 +350,11 @@ class BaseAccount:
|
|||
assert self.encrypted, "Key is not encrypted."
|
||||
try:
|
||||
seed = self._decrypt_seed(password)
|
||||
except ValueError:
|
||||
except (ValueError, InvalidPasswordError):
|
||||
return False
|
||||
try:
|
||||
private_key = self._decrypt_private_key_string(password)
|
||||
except (TypeError, ValueError):
|
||||
except (TypeError, ValueError, InvalidPasswordError):
|
||||
return False
|
||||
self.seed = seed
|
||||
self.private_key = private_key
|
||||
|
|
Loading…
Reference in a new issue