1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 07:18:09 +00:00

legacy: rename TxInfo field overwintered to is_zcashlike

For v3 transaction format see:
https://zips.z.cash/zip-0202#transaction-format-version-3
This commit is contained in:
Martin Milata 2020-07-29 15:09:23 +02:00 committed by Tomas Susanka
parent d955e3f1e5
commit f4c9d0a040
3 changed files with 9 additions and 10 deletions

View File

@ -1356,8 +1356,7 @@ void signing_txack(TransactionType *tx) {
}
tx_init(&tp, tx->inputs_cnt, tx->outputs_cnt, tx->version, tx->lock_time,
tx->expiry, tx->extra_data_len, coin->curve->hasher_sign,
coin->overwintered && tx->version >= 3, tx->version_group_id,
tx->timestamp);
coin->overwintered, tx->version_group_id, tx->timestamp);
#if !BITCOIN_ONLY
if (coin->decred) {
tp.version |= (DECRED_SERIALIZE_NO_WITNESS << 16);

View File

@ -507,7 +507,7 @@ uint32_t tx_serialize_script(uint32_t size, const uint8_t *data, uint8_t *out) {
uint32_t tx_serialize_header(TxStruct *tx, uint8_t *out) {
int r = 4;
#if !BITCOIN_ONLY
if (tx->overwintered) {
if (tx->is_zcashlike && tx->version >= 3) {
uint32_t ver = tx->version | TX_OVERWINTERED;
memcpy(out, &ver, 4);
memcpy(out + 4, &(tx->version_group_id), 4);
@ -533,7 +533,7 @@ uint32_t tx_serialize_header(TxStruct *tx, uint8_t *out) {
uint32_t tx_serialize_header_hash(TxStruct *tx) {
int r = 4;
#if !BITCOIN_ONLY
if (tx->overwintered) {
if (tx->is_zcashlike && tx->version >= 3) {
uint32_t ver = tx->version | TX_OVERWINTERED;
hasher_Update(&(tx->hasher), (const uint8_t *)&ver, 4);
hasher_Update(&(tx->hasher), (const uint8_t *)&(tx->version_group_id), 4);
@ -684,7 +684,7 @@ uint32_t tx_serialize_middle_hash(TxStruct *tx) {
uint32_t tx_serialize_footer(TxStruct *tx, uint8_t *out) {
memcpy(out, &(tx->lock_time), 4);
#if !BITCOIN_ONLY
if (tx->overwintered && tx->version == 4) {
if (tx->is_zcashlike && tx->version == 4) {
memcpy(out + 4, &(tx->expiry), 4);
memzero(out + 8, 8); // valueBalance
out[16] = 0x00; // nShieldedSpend
@ -703,7 +703,7 @@ uint32_t tx_serialize_footer(TxStruct *tx, uint8_t *out) {
uint32_t tx_serialize_footer_hash(TxStruct *tx) {
hasher_Update(&(tx->hasher), (const uint8_t *)&(tx->lock_time), 4);
#if !BITCOIN_ONLY
if (tx->overwintered) {
if (tx->is_zcashlike && tx->version >= 3) {
hasher_Update(&(tx->hasher), (const uint8_t *)&(tx->expiry), 4);
return 8;
}
@ -794,7 +794,7 @@ uint32_t tx_serialize_extra_data_hash(TxStruct *tx, const uint8_t *data,
void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len,
uint32_t version, uint32_t lock_time, uint32_t expiry,
uint32_t extra_data_len, HasherType hasher_sign, bool overwintered,
uint32_t extra_data_len, HasherType hasher_sign, bool is_zcashlike,
uint32_t version_group_id, uint32_t timestamp) {
tx->inputs_len = inputs_len;
tx->outputs_len = outputs_len;
@ -808,7 +808,7 @@ void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len,
tx->size = 0;
tx->is_segwit = false;
tx->is_decred = false;
tx->overwintered = overwintered;
tx->is_zcashlike = is_zcashlike;
tx->version_group_id = version_group_id;
tx->timestamp = timestamp;
hasher_Init(&(tx->hasher), hasher_sign);

View File

@ -41,11 +41,11 @@ typedef struct {
uint32_t expiry;
bool is_segwit;
bool is_decred;
bool is_zcashlike;
uint32_t have_inputs;
uint32_t have_outputs;
bool overwintered;
uint32_t extra_data_len;
uint32_t extra_data_received;
@ -92,7 +92,7 @@ uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxInputType *input,
void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len,
uint32_t version, uint32_t lock_time, uint32_t expiry,
uint32_t extra_data_len, HasherType hasher_sign, bool overwintered,
uint32_t extra_data_len, HasherType hasher_sign, bool is_zcashlike,
uint32_t version_group_id, uint32_t timestamp);
uint32_t tx_serialize_header_hash(TxStruct *tx);
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input);