1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-22 21:30:56 +00:00

enable OP_RETURN

This commit is contained in:
Pavol Rusnak 2015-02-04 20:04:59 +01:00
parent 40efefc571
commit d35b741f08
9 changed files with 33 additions and 12 deletions

View File

@ -126,7 +126,7 @@ void layoutConfirmTx(const CoinType *coin, uint64_t amount_out, uint64_t amount_
"Really send",
str_out,
"from your wallet?",
"Fee will be",
"Fee included:",
str_fee,
NULL
);

View File

@ -13,6 +13,7 @@ TxInputType.script_sig max_size:1650
TxOutputType.address max_size:36
TxOutputType.address_n max_count:8
TxOutputType.op_return_data max_size:80
TxOutputBinType.script_pubkey max_size:520

View File

@ -52,12 +52,13 @@ const pb_field_t TxInputType_fields[8] = {
PB_LAST_FIELD
};
const pb_field_t TxOutputType_fields[6] = {
const pb_field_t TxOutputType_fields[7] = {
PB_FIELD2( 1, STRING , OPTIONAL, STATIC , FIRST, TxOutputType, address, address, 0),
PB_FIELD2( 2, UINT32 , REPEATED, STATIC , OTHER, TxOutputType, address_n, address, 0),
PB_FIELD2( 3, UINT64 , REQUIRED, STATIC , OTHER, TxOutputType, amount, address_n, 0),
PB_FIELD2( 4, ENUM , REQUIRED, STATIC , OTHER, TxOutputType, script_type, amount, 0),
PB_FIELD2( 5, MESSAGE , OPTIONAL, STATIC , OTHER, TxOutputType, multisig, script_type, &MultisigRedeemScriptType_fields),
PB_FIELD2( 6, BYTES , OPTIONAL, STATIC , OTHER, TxOutputType, op_return_data, multisig, 0),
PB_LAST_FIELD
};

View File

@ -27,7 +27,8 @@ typedef enum _FailureType {
typedef enum _OutputScriptType {
OutputScriptType_PAYTOADDRESS = 0,
OutputScriptType_PAYTOSCRIPTHASH = 1,
OutputScriptType_PAYTOMULTISIG = 2
OutputScriptType_PAYTOMULTISIG = 2,
OutputScriptType_PAYTOOPRETURN = 3
} OutputScriptType;
typedef enum _InputScriptType {
@ -187,6 +188,11 @@ typedef struct _TxInputType {
MultisigRedeemScriptType multisig;
} TxInputType;
typedef struct {
size_t size;
uint8_t bytes[80];
} TxOutputType_op_return_data_t;
typedef struct _TxOutputType {
bool has_address;
char address[36];
@ -196,6 +202,8 @@ typedef struct _TxOutputType {
OutputScriptType script_type;
bool has_multisig;
MultisigRedeemScriptType multisig;
bool has_op_return_data;
TxOutputType_op_return_data_t op_return_data;
} TxOutputType;
typedef struct _TransactionType {
@ -233,7 +241,7 @@ extern const InputScriptType TxInputType_script_type_default;
#define CoinType_init_default {false, "", false, "", false, 0u, false, 0, false, 5u}
#define MultisigRedeemScriptType_init_default {0, {HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default, HDNodePathType_init_default}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0}
#define TxInputType_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 4294967295u, false, InputScriptType_SPENDADDRESS, false, MultisigRedeemScriptType_init_default}
#define TxOutputType_init_default {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_default}
#define TxOutputType_init_default {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_default, false, {0, {0}}}
#define TxOutputBinType_init_default {0, {0, {0}}}
#define TransactionType_init_default {false, 0, 0, {TxInputType_init_default}, 0, {TxOutputBinType_init_default}, false, 0, 0, {TxOutputType_init_default}, false, 0, false, 0}
#define TxRequestDetailsType_init_default {false, 0, false, {0, {0}}}
@ -243,7 +251,7 @@ extern const InputScriptType TxInputType_script_type_default;
#define CoinType_init_zero {false, "", false, "", false, 0, false, 0, false, 0}
#define MultisigRedeemScriptType_init_zero {0, {HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero, HDNodePathType_init_zero}, 0, {{0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}}, false, 0}
#define TxInputType_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, {0}}, 0, false, {0, {0}}, false, 0, false, (InputScriptType)0, false, MultisigRedeemScriptType_init_zero}
#define TxOutputType_init_zero {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_zero}
#define TxOutputType_init_zero {false, "", 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, (OutputScriptType)0, false, MultisigRedeemScriptType_init_zero, false, {0, {0}}}
#define TxOutputBinType_init_zero {0, {0, {0}}}
#define TransactionType_init_zero {false, 0, 0, {TxInputType_init_zero}, 0, {TxOutputBinType_init_zero}, false, 0, 0, {TxOutputType_init_zero}, false, 0, false, 0}
#define TxRequestDetailsType_init_zero {false, 0, false, {0, {0}}}
@ -285,6 +293,7 @@ extern const InputScriptType TxInputType_script_type_default;
#define TxOutputType_amount_tag 3
#define TxOutputType_script_type_tag 4
#define TxOutputType_multisig_tag 5
#define TxOutputType_op_return_data_tag 6
#define TransactionType_version_tag 1
#define TransactionType_inputs_tag 2
#define TransactionType_bin_outputs_tag 3
@ -303,7 +312,7 @@ extern const pb_field_t HDNodePathType_fields[3];
extern const pb_field_t CoinType_fields[6];
extern const pb_field_t MultisigRedeemScriptType_fields[4];
extern const pb_field_t TxInputType_fields[8];
extern const pb_field_t TxOutputType_fields[6];
extern const pb_field_t TxOutputType_fields[7];
extern const pb_field_t TxOutputBinType_fields[3];
extern const pb_field_t TransactionType_fields[8];
extern const pb_field_t TxRequestDetailsType_fields[3];
@ -315,9 +324,9 @@ extern const pb_field_t TxRequestSerializedType_fields[4];
#define CoinType_size 53
#define MultisigRedeemScriptType_size 3741
#define TxInputType_size 5497
#define TxOutputType_size 3847
#define TxOutputType_size 3929
#define TxOutputBinType_size 534
#define TransactionType_size 9911
#define TransactionType_size 9993
#define TxRequestDetailsType_size 40
#define TxRequestSerializedType_size 2132

View File

@ -480,7 +480,7 @@ void signing_txack(TransactionType *tx)
}
}
// last confirmation
layoutConfirmTx(coin, to_spend - change_spend - fee, fee);
layoutConfirmTx(coin, to_spend - change_spend, fee);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Signing cancelled by user");
signing_abort();

View File

@ -146,6 +146,16 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
return 23;
}
if (in->script_type == OutputScriptType_PAYTOOPRETURN) {
if (in->amount != 0) return 0; // only 0 satoshi allowed for OP_RETURN
uint32_t r = 0;
out->script_pubkey.bytes[0] = 0x6A; r++; // OP_RETURN
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;
out->script_pubkey.size = r;
return r;
}
return 0;
}

@ -1 +1 @@
Subproject commit 60bcde46f584062e3a454bcdfdcf01bff927c8ea
Subproject commit f5d880c96c72c298e0fb412bcb1abba6a4ddac02

@ -1 +1 @@
Subproject commit aa1833ba3fd9301dd275c1c34c1ce5dd9ae703be
Subproject commit 54aa5a4482eaf6f11c0c6941be5e34aa3a5ff5e2

@ -1 +1 @@
Subproject commit f12996741ca0a73b09e324306c7e79755a84202c
Subproject commit 1da1cedfd6bbd08784a3a4d7d6310b46830893cb