diff --git a/src/apps/wallet/sign_tx/__init__.py b/src/apps/wallet/sign_tx/__init__.py index 2502f2fd8..93252326e 100644 --- a/src/apps/wallet/sign_tx/__init__.py +++ b/src/apps/wallet/sign_tx/__init__.py @@ -19,6 +19,8 @@ async def sign_tx(ctx, msg): req = signer.send(res) except signing.SigningError as e: raise wire.FailureError(*e.args) + except signing.MultisigError as e: + raise wire.FailureError(*e.args) except signing.AddressError as e: raise wire.FailureError(*e.args) except signing.ScriptsError as e: diff --git a/src/apps/wallet/sign_tx/multisig.py b/src/apps/wallet/sign_tx/multisig.py index baa8c1924..8a07b1351 100644 --- a/src/apps/wallet/sign_tx/multisig.py +++ b/src/apps/wallet/sign_tx/multisig.py @@ -3,11 +3,16 @@ from trezor.crypto import bip32 from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType from trezor.messages.HDNodePathType import HDNodePathType +from trezor.messages import FailureType from apps.wallet.sign_tx.writers import * from apps.common.hash_writer import * +class MultisigError(ValueError): + pass + + class MultisigFingerprint: def __init__(self): self.fingerprint = None # multisig fingerprint bytes @@ -36,14 +41,12 @@ def multisig_fingerprint(multisig: MultisigRedeemScriptType) -> bytes: n = len(pubkeys) if n < 1 or n > 15 or m < 1 or m > 15: - raise SigningError(FailureType.DataError, - 'Invalid multisig parameters') + raise MultisigError(FailureType.DataError, 'Invalid multisig parameters') for hd in pubkeys: d = hd.node if len(d.public_key) != 33 or len(d.chain_code) != 32: - raise SigningError(FailureType.DataError, - 'Invalid multisig parameters') + raise MultisigError(FailureType.DataError, 'Invalid multisig parameters') # casting to bytes(), sorting on bytearray() is not supported in MicroPython pubkeys = sorted(pubkeys, key=lambda hd: bytes(hd.node.public_key)) @@ -66,7 +69,7 @@ def multisig_pubkey_index(multisig: MultisigRedeemScriptType, pubkey: bytes) -> for i, hd in enumerate(multisig.pubkeys): if multisig_get_pubkey(hd) == pubkey: return i - raise SigningError(FailureType.DataError, + raise MultisigError(FailureType.DataError, 'Pubkey not found in multisig script')