From f4c9d0a04015027b8f32996abb646b942b9bc058 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 29 Jul 2020 15:09:23 +0200 Subject: [PATCH] legacy: rename TxInfo field overwintered to is_zcashlike For v3 transaction format see: https://zips.z.cash/zip-0202#transaction-format-version-3 --- legacy/firmware/signing.c | 3 +-- legacy/firmware/transaction.c | 12 ++++++------ legacy/firmware/transaction.h | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/legacy/firmware/signing.c b/legacy/firmware/signing.c index 0bd7633e14..5bda102ec9 100644 --- a/legacy/firmware/signing.c +++ b/legacy/firmware/signing.c @@ -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); diff --git a/legacy/firmware/transaction.c b/legacy/firmware/transaction.c index df608ea280..ebad6f9404 100644 --- a/legacy/firmware/transaction.c +++ b/legacy/firmware/transaction.c @@ -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); diff --git a/legacy/firmware/transaction.h b/legacy/firmware/transaction.h index 9f85f674db..5784c1e268 100644 --- a/legacy/firmware/transaction.h +++ b/legacy/firmware/transaction.h @@ -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);