mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 20:38:10 +00:00
chore(legacy): Recognize Taproot script types.
This commit is contained in:
parent
6c9c727359
commit
aed79eec65
@ -920,6 +920,7 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin,
|
|||||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
||||||
static bool is_multisig_input_script_type(const TxInputType *txinput) {
|
static bool is_multisig_input_script_type(const TxInputType *txinput) {
|
||||||
|
// we do not support Multisig with Taproot yet
|
||||||
if (txinput->script_type == InputScriptType_SPENDMULTISIG ||
|
if (txinput->script_type == InputScriptType_SPENDMULTISIG ||
|
||||||
txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
|
txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
|
||||||
txinput->script_type == InputScriptType_SPENDWITNESS) {
|
txinput->script_type == InputScriptType_SPENDWITNESS) {
|
||||||
@ -929,6 +930,7 @@ static bool is_multisig_input_script_type(const TxInputType *txinput) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool is_multisig_output_script_type(const TxOutputType *txoutput) {
|
static bool is_multisig_output_script_type(const TxOutputType *txoutput) {
|
||||||
|
// we do not support Multisig with Taproot yet
|
||||||
if (txoutput->script_type == OutputScriptType_PAYTOMULTISIG ||
|
if (txoutput->script_type == OutputScriptType_PAYTOMULTISIG ||
|
||||||
txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS ||
|
txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS ||
|
||||||
txoutput->script_type == OutputScriptType_PAYTOWITNESS) {
|
txoutput->script_type == OutputScriptType_PAYTOWITNESS) {
|
||||||
@ -941,7 +943,8 @@ static bool is_internal_input_script_type(const TxInputType *txinput) {
|
|||||||
if (txinput->script_type == InputScriptType_SPENDADDRESS ||
|
if (txinput->script_type == InputScriptType_SPENDADDRESS ||
|
||||||
txinput->script_type == InputScriptType_SPENDMULTISIG ||
|
txinput->script_type == InputScriptType_SPENDMULTISIG ||
|
||||||
txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
|
txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
|
||||||
txinput->script_type == InputScriptType_SPENDWITNESS) {
|
txinput->script_type == InputScriptType_SPENDWITNESS ||
|
||||||
|
txinput->script_type == InputScriptType_SPENDTAPROOT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -951,7 +954,8 @@ static bool is_change_output_script_type(const TxOutputType *txoutput) {
|
|||||||
if (txoutput->script_type == OutputScriptType_PAYTOADDRESS ||
|
if (txoutput->script_type == OutputScriptType_PAYTOADDRESS ||
|
||||||
txoutput->script_type == OutputScriptType_PAYTOMULTISIG ||
|
txoutput->script_type == OutputScriptType_PAYTOMULTISIG ||
|
||||||
txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS ||
|
txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS ||
|
||||||
txoutput->script_type == OutputScriptType_PAYTOWITNESS) {
|
txoutput->script_type == OutputScriptType_PAYTOWITNESS ||
|
||||||
|
txoutput->script_type == OutputScriptType_PAYTOTAPROOT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -959,7 +963,17 @@ static bool is_change_output_script_type(const TxOutputType *txoutput) {
|
|||||||
|
|
||||||
static bool is_segwit_input_script_type(const TxInputType *txinput) {
|
static bool is_segwit_input_script_type(const TxInputType *txinput) {
|
||||||
if (txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
|
if (txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
|
||||||
txinput->script_type == InputScriptType_SPENDWITNESS) {
|
txinput->script_type == InputScriptType_SPENDWITNESS ||
|
||||||
|
txinput->script_type == InputScriptType_SPENDTAPROOT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_segwit_output_script_type(const TxOutputType *txoutput) {
|
||||||
|
if (txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS ||
|
||||||
|
txoutput->script_type == OutputScriptType_PAYTOWITNESS ||
|
||||||
|
txoutput->script_type == OutputScriptType_PAYTOTAPROOT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -980,9 +994,9 @@ static bool signing_validate_input(const TxInputType *txinput) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txinput->address_n_count > 0 && !is_internal_input_script_type(txinput)) {
|
if (!is_internal_input_script_type(txinput)) {
|
||||||
fsm_sendFailure(FailureType_Failure_DataError,
|
fsm_sendFailure(FailureType_Failure_DataError,
|
||||||
"Input's address_n provided but not expected.");
|
_("Unsupported script type."));
|
||||||
signing_abort();
|
signing_abort();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -996,6 +1010,14 @@ static bool signing_validate_input(const TxInputType *txinput) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (txinput->script_type == InputScriptType_SPENDTAPROOT &&
|
||||||
|
!coin->has_taproot) {
|
||||||
|
fsm_sendFailure(FailureType_Failure_DataError,
|
||||||
|
_("Taproot not enabled on this coin."));
|
||||||
|
signing_abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (txinput->has_orig_hash) {
|
if (txinput->has_orig_hash) {
|
||||||
if (!txinput->has_orig_index) {
|
if (!txinput->has_orig_index) {
|
||||||
fsm_sendFailure(FailureType_Failure_DataError,
|
fsm_sendFailure(FailureType_Failure_DataError,
|
||||||
@ -1065,6 +1087,23 @@ static bool signing_validate_output(TxOutputType *txoutput) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_segwit_output_script_type(txoutput)) {
|
||||||
|
if (!coin->has_segwit) {
|
||||||
|
fsm_sendFailure(FailureType_Failure_DataError,
|
||||||
|
_("Segwit not enabled on this coin"));
|
||||||
|
signing_abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (txoutput->script_type == OutputScriptType_PAYTOTAPROOT &&
|
||||||
|
!coin->has_taproot) {
|
||||||
|
fsm_sendFailure(FailureType_Failure_DataError,
|
||||||
|
_("Taproot not enabled on this coin."));
|
||||||
|
signing_abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (txoutput->has_orig_hash) {
|
if (txoutput->has_orig_hash) {
|
||||||
if (!txoutput->has_orig_index) {
|
if (!txoutput->has_orig_index) {
|
||||||
fsm_sendFailure(FailureType_Failure_DataError,
|
fsm_sendFailure(FailureType_Failure_DataError,
|
||||||
|
@ -273,6 +273,9 @@ int compile_output(const CoinInfo *coin, AmountUnit amount_unit,
|
|||||||
case OutputScriptType_PAYTOP2SHWITNESS:
|
case OutputScriptType_PAYTOP2SHWITNESS:
|
||||||
input_script_type = InputScriptType_SPENDP2SHWITNESS;
|
input_script_type = InputScriptType_SPENDP2SHWITNESS;
|
||||||
break;
|
break;
|
||||||
|
case OutputScriptType_PAYTOTAPROOT:
|
||||||
|
input_script_type = InputScriptType_SPENDTAPROOT;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return 0; // failed to compile output
|
return 0; // failed to compile output
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user