mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
firmware: don't use hardcoded version_group_id, but use the one from coin definition
This commit is contained in:
parent
dca28f1c44
commit
3de28570e4
@ -511,13 +511,13 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin, const HDNode *_root)
|
||||
multisig_fp_mismatch = false;
|
||||
next_nonsegwit_input = 0xffffffff;
|
||||
|
||||
tx_init(&to, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered);
|
||||
tx_init(&to, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered, coin->version_group_id);
|
||||
|
||||
if (coin->decred) {
|
||||
to.version |= (DECRED_SERIALIZE_FULL << 16);
|
||||
to.is_decred = true;
|
||||
|
||||
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered);
|
||||
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered, coin->version_group_id);
|
||||
ti.version |= (DECRED_SERIALIZE_NO_WITNESS << 16);
|
||||
ti.is_decred = true;
|
||||
}
|
||||
@ -1046,7 +1046,7 @@ void signing_txack(TxAck_TransactionType *tx)
|
||||
signing_abort();
|
||||
return;
|
||||
}
|
||||
tx_init(&tp, tx->inputs_cnt, tx->outputs_cnt, tx->version, tx->lock_time, tx->expiry, tx->extra_data_len, coin->curve->hasher_sign, overwintered);
|
||||
tx_init(&tp, tx->inputs_cnt, tx->outputs_cnt, tx->version, tx->lock_time, tx->expiry, tx->extra_data_len, coin->curve->hasher_sign, overwintered, coin->version_group_id);
|
||||
if (coin->decred) {
|
||||
tp.version |= (DECRED_SERIALIZE_NO_WITNESS << 16);
|
||||
tp.is_decred = true;
|
||||
@ -1129,7 +1129,7 @@ void signing_txack(TxAck_TransactionType *tx)
|
||||
case STAGE_REQUEST_4_INPUT:
|
||||
progress = 500 + ((signatures * progress_step + idx2 * progress_meta_step) >> PROGRESS_PRECISION);
|
||||
if (idx2 == 0) {
|
||||
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered);
|
||||
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered, coin->version_group_id);
|
||||
hasher_Reset(&hasher_check);
|
||||
}
|
||||
// check prevouts and script type
|
||||
@ -1328,12 +1328,12 @@ void signing_txack(TxAck_TransactionType *tx)
|
||||
progress = 500 + ((signatures * progress_step + idx2 * progress_meta_step) >> PROGRESS_PRECISION);
|
||||
if (idx1 == 0) {
|
||||
// witness
|
||||
tx_init(&to, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered);
|
||||
tx_init(&to, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered, coin->version_group_id);
|
||||
to.is_decred = true;
|
||||
}
|
||||
|
||||
// witness hash
|
||||
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered);
|
||||
tx_init(&ti, inputs_count, outputs_count, version, lock_time, expiry, 0, coin->curve->hasher_sign, overwintered, coin->version_group_id);
|
||||
ti.version |= (DECRED_SERIALIZE_WITNESS_SIGNING << 16);
|
||||
ti.is_decred = true;
|
||||
if (!compile_input_script_sig(&tx->inputs[0])) {
|
||||
|
@ -467,8 +467,7 @@ uint32_t tx_serialize_header(TxStruct *tx, uint8_t *out)
|
||||
if (tx->overwintered) {
|
||||
uint32_t ver = tx->version | TX_OVERWINTERED;
|
||||
memcpy(out, &ver, 4);
|
||||
uint32_t version_group_id = 0x03c48270;
|
||||
memcpy(out + 4, &version_group_id, 4);
|
||||
memcpy(out + 4, &(tx->version_group_id), 4);
|
||||
r += 4;
|
||||
} else {
|
||||
memcpy(out, &(tx->version), 4);
|
||||
@ -486,8 +485,7 @@ uint32_t tx_serialize_header_hash(TxStruct *tx)
|
||||
if (tx->overwintered) {
|
||||
uint32_t ver = tx->version | TX_OVERWINTERED;
|
||||
hasher_Update(&(tx->hasher), (const uint8_t *)&ver, 4);
|
||||
uint32_t version_group_id = 0x03c48270;
|
||||
hasher_Update(&(tx->hasher), (const uint8_t *)&version_group_id, 4);
|
||||
hasher_Update(&(tx->hasher), (const uint8_t *)&(tx->version_group_id), 4);
|
||||
r += 4;
|
||||
} else {
|
||||
hasher_Update(&(tx->hasher), (const uint8_t *)&(tx->version), 4);
|
||||
@ -713,7 +711,7 @@ uint32_t tx_serialize_extra_data_hash(TxStruct *tx, const uint8_t *data, uint32_
|
||||
return datalen;
|
||||
}
|
||||
|
||||
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)
|
||||
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 version_group_id)
|
||||
{
|
||||
tx->inputs_len = inputs_len;
|
||||
tx->outputs_len = outputs_len;
|
||||
@ -728,6 +726,7 @@ void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t v
|
||||
tx->is_segwit = false;
|
||||
tx->is_decred = false;
|
||||
tx->overwintered = overwintered;
|
||||
tx->version_group_id = version_group_id;
|
||||
hasher_Init(&(tx->hasher), hasher_sign);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ typedef struct {
|
||||
uint32_t outputs_len;
|
||||
|
||||
uint32_t version;
|
||||
uint32_t version_group_id;
|
||||
uint32_t lock_time;
|
||||
uint32_t expiry;
|
||||
bool is_segwit;
|
||||
@ -71,7 +72,7 @@ uint32_t tx_serialize_input(TxStruct *tx, const TxAck_TransactionType_TxInputTyp
|
||||
uint32_t tx_serialize_output(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output, uint8_t *out);
|
||||
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxAck_TransactionType_TxInputType *input, uint8_t *out);
|
||||
|
||||
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);
|
||||
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 version_group_id);
|
||||
uint32_t tx_serialize_header_hash(TxStruct *tx);
|
||||
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxAck_TransactionType_TxInputType *input);
|
||||
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxAck_TransactionType_TxOutputBinType *output);
|
||||
|
Loading…
Reference in New Issue
Block a user