mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
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:
@@ -463,9 +463,9 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
self.log.info("Test transaction version numbers")
|
||||
|
||||
# Test the minimum transaction version number that fits in a signed 32-bit integer.
|
||||
# As transaction version is unsigned, this should convert to its unsigned equivalent.
|
||||
# As transaction version is serialized unsigned, this should convert to its unsigned equivalent.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = -0x80000000
|
||||
tx.nVersion = 0x80000000
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0x80000000)
|
||||
@@ -477,6 +477,20 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0x7fffffff)
|
||||
|
||||
# Test the minimum transaction version number that fits in an unsigned 32-bit integer.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 0
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0)
|
||||
|
||||
# Test the maximum transaction version number that fits in an unsigned 32-bit integer.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 0xffffffff
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0xffffffff)
|
||||
|
||||
def raw_multisig_transaction_legacy_tests(self):
|
||||
self.log.info("Test raw multisig transactions (legacy)")
|
||||
# The traditional multisig workflow does not work with descriptor wallets so these are legacy only.
|
||||
|
||||
Reference in New Issue
Block a user