|
|
|
@ -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);
|
|
|
|
|