chore(legacy): Recognize Taproot script types.

pull/1926/head
Andrew Kozlik 3 years ago committed by Andrew Kozlik
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))
static bool is_multisig_input_script_type(const TxInputType *txinput) {
// we do not support Multisig with Taproot yet
if (txinput->script_type == InputScriptType_SPENDMULTISIG ||
txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
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) {
// we do not support Multisig with Taproot yet
if (txoutput->script_type == OutputScriptType_PAYTOMULTISIG ||
txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS ||
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 ||
txinput->script_type == InputScriptType_SPENDMULTISIG ||
txinput->script_type == InputScriptType_SPENDP2SHWITNESS ||
txinput->script_type == InputScriptType_SPENDWITNESS) {
txinput->script_type == InputScriptType_SPENDWITNESS ||
txinput->script_type == InputScriptType_SPENDTAPROOT) {
return true;
}
return false;
@ -951,7 +954,8 @@ static bool is_change_output_script_type(const TxOutputType *txoutput) {
if (txoutput->script_type == OutputScriptType_PAYTOADDRESS ||
txoutput->script_type == OutputScriptType_PAYTOMULTISIG ||
txoutput->script_type == OutputScriptType_PAYTOP2SHWITNESS ||
txoutput->script_type == OutputScriptType_PAYTOWITNESS) {
txoutput->script_type == OutputScriptType_PAYTOWITNESS ||
txoutput->script_type == OutputScriptType_PAYTOTAPROOT) {
return true;
}
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) {
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 false;
@ -980,9 +994,9 @@ static bool signing_validate_input(const TxInputType *txinput) {
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,
"Input's address_n provided but not expected.");
_("Unsupported script type."));
signing_abort();
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_index) {
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_index) {
fsm_sendFailure(FailureType_Failure_DataError,

@ -273,6 +273,9 @@ int compile_output(const CoinInfo *coin, AmountUnit amount_unit,
case OutputScriptType_PAYTOP2SHWITNESS:
input_script_type = InputScriptType_SPENDP2SHWITNESS;
break;
case OutputScriptType_PAYTOTAPROOT:
input_script_type = InputScriptType_SPENDTAPROOT;
break;
default:
return 0; // failed to compile output
}

Loading…
Cancel
Save