From 2c90304f3a218b87a27462b605db656030ac4888 Mon Sep 17 00:00:00 2001 From: David Misiak Date: Thu, 11 Nov 2021 18:35:53 +0100 Subject: [PATCH] fixup! feat(cardano): add support for plutus transactions --- core/src/apps/cardano/sign_tx.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/core/src/apps/cardano/sign_tx.py b/core/src/apps/cardano/sign_tx.py index 1af53971dad..924fab16254 100644 --- a/core/src/apps/cardano/sign_tx.py +++ b/core/src/apps/cardano/sign_tx.py @@ -92,7 +92,6 @@ POOL_OWNER_STAKING_PATH_NAME, SCHEMA_MINT, SCHEMA_PAYMENT, - SCHEMA_PUBKEY, SCHEMA_STAKING, SCHEMA_STAKING_ANY_ACCOUNT, WITNESS_PATH_NAME, @@ -127,7 +126,7 @@ show_warning_tx_output_contains_datum_hash, show_warning_tx_output_contains_tokens, ) -from .seed import is_byron_path, is_multisig_path, is_shelley_path +from .seed import is_byron_path, is_minting_path, is_multisig_path, is_shelley_path if False: from typing import Any, Union @@ -1053,7 +1052,11 @@ def _validate_required_signer(required_signer: CardanoTxRequiredSigner) -> None: if len(required_signer.key_hash) != ADDRESS_KEY_HASH_SIZE: raise INVALID_REQUIRED_SIGNER elif required_signer.key_path: - if not SCHEMA_PUBKEY.match(required_signer.key_path): # TODO use correct schema + if not ( + is_shelley_path(required_signer.key_path) + or is_multisig_path(required_signer.key_path) + or is_minting_path(required_signer.key_path) + ): raise INVALID_REQUIRED_SIGNER else: raise INVALID_REQUIRED_SIGNER @@ -1163,7 +1166,14 @@ def _validate_witness_request( if is_minting and not transaction_has_token_minting: raise INVALID_WITNESS_REQUEST elif signing_mode == CardanoTxSigningMode.PLUTUS_TRANSACTION: - pass + if not ( + is_shelley_path(witness_request.path) + or is_multisig_path(witness_request.path) + or is_minting + ): + raise INVALID_WITNESS_REQUEST + if is_minting and not transaction_has_token_minting: + raise INVALID_WITNESS_REQUEST else: raise RuntimeError # we didn't cover all signing modes