mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-23 07:58:09 +00:00
transaction: fix compile_output for OP_RETURN
This commit is contained in:
parent
8e017526ab
commit
38970cbd68
@ -161,23 +161,24 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
|
|||||||
size_t addr_raw_len;
|
size_t addr_raw_len;
|
||||||
bool is_segwit;
|
bool is_segwit;
|
||||||
|
|
||||||
if (in->address_n_count > 0) {
|
if (in->script_type == OutputScriptType_PAYTOOPRETURN) {
|
||||||
HDNode node;
|
|
||||||
InputScriptType input_script_type;
|
|
||||||
|
|
||||||
switch (in->script_type) {
|
|
||||||
|
|
||||||
case OutputScriptType_PAYTOOPRETURN:
|
|
||||||
// only 0 satoshi allowed for OP_RETURN
|
// only 0 satoshi allowed for OP_RETURN
|
||||||
if (in->amount != 0)
|
if (in->amount != 0) {
|
||||||
return 0; // failed to compile output
|
return 0; // failed to compile output
|
||||||
|
}
|
||||||
uint32_t r = 0;
|
uint32_t r = 0;
|
||||||
out->script_pubkey.bytes[0] = 0x6A; r++; // OP_RETURN
|
out->script_pubkey.bytes[0] = 0x6A; r++; // OP_RETURN
|
||||||
r += op_push(in->op_return_data.size, out->script_pubkey.bytes + r);
|
r += op_push(in->op_return_data.size, out->script_pubkey.bytes + r);
|
||||||
memcpy(out->script_pubkey.bytes + r, in->op_return_data.bytes, in->op_return_data.size); r += in->op_return_data.size;
|
memcpy(out->script_pubkey.bytes + r, in->op_return_data.bytes, in->op_return_data.size); r += in->op_return_data.size;
|
||||||
out->script_pubkey.size = r;
|
out->script_pubkey.size = r;
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in->address_n_count > 0) {
|
||||||
|
HDNode node;
|
||||||
|
InputScriptType input_script_type;
|
||||||
|
|
||||||
|
switch (in->script_type) {
|
||||||
case OutputScriptType_PAYTOADDRESS:
|
case OutputScriptType_PAYTOADDRESS:
|
||||||
input_script_type = InputScriptType_SPENDADDRESS;
|
input_script_type = InputScriptType_SPENDADDRESS;
|
||||||
break;
|
break;
|
||||||
@ -190,7 +191,6 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
|
|||||||
case OutputScriptType_PAYTOP2SHWITNESS:
|
case OutputScriptType_PAYTOP2SHWITNESS:
|
||||||
input_script_type = InputScriptType_SPENDP2SHWITNESS;
|
input_script_type = InputScriptType_SPENDP2SHWITNESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0; // failed to compile output
|
return 0; // failed to compile output
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user