1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-12 00:10:58 +00:00

legacy/signing: Check inputs for amount field only when amount is required.

This commit is contained in:
Andrew Kozlik 2020-03-27 16:42:50 +01:00 committed by Tomas Susanka
parent d34428eeb3
commit 386be6ff09

View File

@ -674,17 +674,6 @@ static bool signing_validate_input(const TxInputType *txinput) {
return false; 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 (is_segwit_input_script_type(txinput)) {
if (!coin->has_segwit) { if (!coin->has_segwit) {
fsm_sendFailure(FailureType_Failure_DataError, fsm_sendFailure(FailureType_Failure_DataError,
@ -692,12 +681,6 @@ static bool signing_validate_input(const TxInputType *txinput) {
signing_abort(); signing_abort();
return false; return false;
} }
if (!txinput->has_amount) {
fsm_sendFailure(FailureType_Failure_DataError,
_("Segwit input without amount"));
signing_abort();
return false;
}
} }
return true; return true;
@ -1159,6 +1142,12 @@ static bool signing_sign_segwit_input(TxInputType *txinput) {
uint8_t hash[32] = {0}; uint8_t hash[32] = {0};
if (is_segwit_input_script_type(txinput)) { 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)) { if (!compile_input_script_sig(txinput)) {
fsm_sendFailure(FailureType_Failure_ProcessError, fsm_sendFailure(FailureType_Failure_ProcessError,
_("Failed to compile input")); _("Failed to compile input"));
@ -1617,6 +1606,12 @@ void signing_txack(TransactionType *tx) {
signing_abort(); signing_abort();
return; return;
} }
if (!tx->inputs[0].has_amount) {
fsm_sendFailure(FailureType_Failure_DataError,
_("Expected input with amount"));
signing_abort();
return;
}
uint8_t hash[32] = {0}; uint8_t hash[32] = {0};
#if !BITCOIN_ONLY #if !BITCOIN_ONLY