mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
disable native segwit for now
This commit is contained in:
parent
49f44d296c
commit
24ac52079f
@ -92,14 +92,6 @@ bool coinExtractAddressTypeRaw(const CoinType *coin, const uint8_t *addr_raw, ui
|
|||||||
*address_type = coin->address_type_p2sh;
|
*address_type = coin->address_type_p2sh;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (coin->has_address_type_p2wpkh && address_check_prefix(addr_raw, coin->address_type_p2wpkh)) {
|
|
||||||
*address_type = coin->address_type_p2wpkh;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (coin->has_address_type_p2wsh && address_check_prefix(addr_raw, coin->address_type_p2wsh)) {
|
|
||||||
*address_type = coin->address_type_p2wsh;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*address_type = 0;
|
*address_type = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -656,6 +656,12 @@ static bool signing_sign_segwit_input(TxInputType *txinput) {
|
|||||||
|
|
||||||
if (txinput->script_type == InputScriptType_SPENDWITNESS
|
if (txinput->script_type == InputScriptType_SPENDWITNESS
|
||||||
|| txinput->script_type == InputScriptType_SPENDP2SHWITNESS) {
|
|| txinput->script_type == InputScriptType_SPENDP2SHWITNESS) {
|
||||||
|
// disable native segwit for now
|
||||||
|
if (txinput->script_type == InputScriptType_SPENDWITNESS) {
|
||||||
|
fsm_sendFailure(FailureType_Failure_Other, "Native segwit is disabled");
|
||||||
|
signing_abort();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!compile_input_script_sig(txinput)) {
|
if (!compile_input_script_sig(txinput)) {
|
||||||
fsm_sendFailure(FailureType_Failure_Other, "Failed to compile input");
|
fsm_sendFailure(FailureType_Failure_Other, "Failed to compile input");
|
||||||
signing_abort();
|
signing_abort();
|
||||||
@ -793,6 +799,12 @@ void signing_txack(TransactionType *tx)
|
|||||||
signing_abort();
|
signing_abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// disable native segwit for now
|
||||||
|
if (tx->inputs[0].script_type == InputScriptType_SPENDWITNESS) {
|
||||||
|
fsm_sendFailure(FailureType_Failure_Other, "Native segwit is disabled");
|
||||||
|
signing_abort();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!tx->inputs[0].has_amount) {
|
if (!tx->inputs[0].has_amount) {
|
||||||
fsm_sendFailure(FailureType_Failure_Other, "Segwit input without amount");
|
fsm_sendFailure(FailureType_Failure_Other, "Segwit input without amount");
|
||||||
signing_abort();
|
signing_abort();
|
||||||
|
@ -80,17 +80,8 @@ bool compute_address(const CoinType *coin,
|
|||||||
if (!coin->has_segwit || !coin->segwit) {
|
if (!coin->has_segwit || !coin->segwit) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!coin->has_address_type_p2wsh) {
|
// disable native segwit for now
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
prelen = address_prefix_bytes_len(coin->address_type_p2wsh);
|
|
||||||
address_write_prefix_bytes(coin->address_type_p2wsh, raw);
|
|
||||||
raw[prelen] = 0; // version byte
|
|
||||||
raw[prelen + 1] = 0; // always 0, see bip-142
|
|
||||||
memcpy(raw+prelen+2, digest, 32);
|
|
||||||
if (!base58_encode_check(raw, prelen + 34, address, MAX_ADDR_SIZE)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else if (script_type == InputScriptType_SPENDP2SHWITNESS) {
|
} else if (script_type == InputScriptType_SPENDP2SHWITNESS) {
|
||||||
// segwit p2wsh encapsuled in p2sh address
|
// segwit p2wsh encapsuled in p2sh address
|
||||||
if (!coin->has_segwit || !coin->segwit) {
|
if (!coin->has_segwit || !coin->segwit) {
|
||||||
@ -123,17 +114,8 @@ bool compute_address(const CoinType *coin,
|
|||||||
if (!coin->has_segwit || !coin->segwit) {
|
if (!coin->has_segwit || !coin->segwit) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!coin->has_address_type_p2wpkh) {
|
// disable native segwit for now
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
prelen = address_prefix_bytes_len(coin->address_type_p2wpkh);
|
|
||||||
address_write_prefix_bytes(coin->address_type_p2wpkh, raw);
|
|
||||||
raw[prelen] = 0; // version byte
|
|
||||||
raw[prelen + 1] = 0; // always 0, see bip-142
|
|
||||||
ecdsa_get_pubkeyhash(node->public_key, raw + prelen + 2);
|
|
||||||
if (!base58_encode_check(raw, prelen + 22, address, MAX_ADDR_SIZE)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else if (script_type == InputScriptType_SPENDP2SHWITNESS) {
|
} else if (script_type == InputScriptType_SPENDP2SHWITNESS) {
|
||||||
// segwit p2wpkh embedded in p2sh
|
// segwit p2wpkh embedded in p2sh
|
||||||
if (!coin->has_segwit || !coin->segwit) {
|
if (!coin->has_segwit || !coin->segwit) {
|
||||||
@ -190,8 +172,8 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
|
|||||||
input_script_type = InputScriptType_SPENDMULTISIG;
|
input_script_type = InputScriptType_SPENDMULTISIG;
|
||||||
break;
|
break;
|
||||||
case OutputScriptType_PAYTOWITNESS:
|
case OutputScriptType_PAYTOWITNESS:
|
||||||
input_script_type = InputScriptType_SPENDWITNESS;
|
// disable native segwit for now
|
||||||
break;
|
return 0;
|
||||||
case OutputScriptType_PAYTOP2SHWITNESS:
|
case OutputScriptType_PAYTOP2SHWITNESS:
|
||||||
input_script_type = InputScriptType_SPENDP2SHWITNESS;
|
input_script_type = InputScriptType_SPENDP2SHWITNESS;
|
||||||
break;
|
break;
|
||||||
@ -215,8 +197,7 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
|
|||||||
addr_raw_len = base58_decode_check(in->address, addr_raw, MAX_ADDR_RAW_SIZE);
|
addr_raw_len = base58_decode_check(in->address, addr_raw, MAX_ADDR_RAW_SIZE);
|
||||||
size_t prefix_len;
|
size_t prefix_len;
|
||||||
if (address_check_prefix(addr_raw, coin->address_type) // p2pkh
|
if (address_check_prefix(addr_raw, coin->address_type) // p2pkh
|
||||||
&& addr_raw_len == 20 + (prefix_len = address_prefix_bytes_len(coin->address_type))) {
|
&& addr_raw_len == 20 + (prefix_len = address_prefix_bytes_len(coin->address_type))) {
|
||||||
|
|
||||||
out->script_pubkey.bytes[0] = 0x76; // OP_DUP
|
out->script_pubkey.bytes[0] = 0x76; // OP_DUP
|
||||||
out->script_pubkey.bytes[1] = 0xA9; // OP_HASH_160
|
out->script_pubkey.bytes[1] = 0xA9; // OP_HASH_160
|
||||||
out->script_pubkey.bytes[2] = 0x14; // pushing 20 bytes
|
out->script_pubkey.bytes[2] = 0x14; // pushing 20 bytes
|
||||||
@ -231,20 +212,6 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
|
|||||||
memcpy(out->script_pubkey.bytes + 2, addr_raw + prefix_len, 20);
|
memcpy(out->script_pubkey.bytes + 2, addr_raw + prefix_len, 20);
|
||||||
out->script_pubkey.bytes[22] = 0x87; // OP_EQUAL
|
out->script_pubkey.bytes[22] = 0x87; // OP_EQUAL
|
||||||
out->script_pubkey.size = 23;
|
out->script_pubkey.size = 23;
|
||||||
} else if (address_check_prefix(addr_raw, coin->address_type_p2wpkh)
|
|
||||||
&& addr_raw_len == 22 + (prefix_len = address_prefix_bytes_len(coin->address_type_p2wpkh))
|
|
||||||
&& addr_raw[prefix_len] == 0 && addr_raw[prefix_len + 1] == 0) { // p2wpkh v0
|
|
||||||
out->script_pubkey.bytes[0] = 0x00; // version 0
|
|
||||||
out->script_pubkey.bytes[1] = 0x14; // pushing 20 bytes
|
|
||||||
memcpy(out->script_pubkey.bytes + 2, addr_raw + prefix_len + 2, 20);
|
|
||||||
out->script_pubkey.size = 22;
|
|
||||||
} else if (address_check_prefix(addr_raw, coin->address_type_p2wsh)
|
|
||||||
&& addr_raw_len == 34 + (prefix_len = address_prefix_bytes_len(coin->address_type_p2wsh))
|
|
||||||
&& addr_raw[prefix_len] == 0 && addr_raw[prefix_len + 1] == 0) { // p2wsh v0
|
|
||||||
out->script_pubkey.bytes[0] = 0x00; // version 0
|
|
||||||
out->script_pubkey.bytes[1] = 0x20; // pushing 32 bytes
|
|
||||||
memcpy(out->script_pubkey.bytes + 2, addr_raw + prefix_len + 2, 32);
|
|
||||||
out->script_pubkey.size = 34;
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user