From 386be6ff09acf5c0104751f1fc9c236c76d78525 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Fri, 27 Mar 2020 16:42:50 +0100 Subject: [PATCH] legacy/signing: Check inputs for amount field only when amount is required. --- legacy/firmware/signing.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/legacy/firmware/signing.c b/legacy/firmware/signing.c index 1cfcf4c30..51ab2f70b 100644 --- a/legacy/firmware/signing.c +++ b/legacy/firmware/signing.c @@ -674,17 +674,6 @@ static bool signing_validate_input(const TxInputType *txinput) { return false; } -#if !BITCOIN_ONLY - if (coin->force_bip143 || coin->overwintered) { - if (!txinput->has_amount) { - fsm_sendFailure(FailureType_Failure_DataError, - _("Expected input with amount")); - signing_abort(); - return false; - } - } -#endif - if (is_segwit_input_script_type(txinput)) { if (!coin->has_segwit) { fsm_sendFailure(FailureType_Failure_DataError, @@ -692,12 +681,6 @@ static bool signing_validate_input(const TxInputType *txinput) { signing_abort(); return false; } - if (!txinput->has_amount) { - fsm_sendFailure(FailureType_Failure_DataError, - _("Segwit input without amount")); - signing_abort(); - return false; - } } return true; @@ -1159,6 +1142,12 @@ static bool signing_sign_segwit_input(TxInputType *txinput) { uint8_t hash[32] = {0}; if (is_segwit_input_script_type(txinput)) { + if (!txinput->has_amount) { + fsm_sendFailure(FailureType_Failure_DataError, + _("Segwit input without amount")); + signing_abort(); + return false; + } if (!compile_input_script_sig(txinput)) { fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile input")); @@ -1617,6 +1606,12 @@ void signing_txack(TransactionType *tx) { signing_abort(); return; } + if (!tx->inputs[0].has_amount) { + fsm_sendFailure(FailureType_Failure_DataError, + _("Expected input with amount")); + signing_abort(); + return; + } uint8_t hash[32] = {0}; #if !BITCOIN_ONLY