consensus: Store transaction nVersion as uint32_t

Given that the use of a transaction's nVersion is always as an unsigned
int, it doesn't make sense to store it as signed and then cast it to
unsigned.
This commit is contained in:
Ava Chow
2024-01-25 16:27:08 -05:00
parent 6e4d18f37f
commit 27e70f1f5b
16 changed files with 47 additions and 39 deletions

View File

@@ -738,7 +738,7 @@ def SegwitV0SignatureMsg(script, txTo, inIdx, hashtype, amount):
hashOutputs = uint256_from_str(hash256(serialize_outputs))
ss = bytes()
ss += txTo.nVersion.to_bytes(4, "little", signed=True)
ss += txTo.nVersion.to_bytes(4, "little")
ss += ser_uint256(hashPrevouts)
ss += ser_uint256(hashSequence)
ss += txTo.vin[inIdx].prevout.serialize()
@@ -817,7 +817,7 @@ def TaprootSignatureMsg(txTo, spent_utxos, hash_type, input_index = 0, scriptpat
in_type = hash_type & SIGHASH_ANYONECANPAY
spk = spent_utxos[input_index].scriptPubKey
ss = bytes([0, hash_type]) # epoch, hash_type
ss += txTo.nVersion.to_bytes(4, "little", signed=True)
ss += txTo.nVersion.to_bytes(4, "little")
ss += txTo.nLockTime.to_bytes(4, "little")
if in_type != SIGHASH_ANYONECANPAY:
ss += BIP341_sha_prevouts(txTo)