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

@@ -45,7 +45,7 @@ CMutableTransaction ConsumeTransaction(FuzzedDataProvider& fuzzed_data_provider,
const auto p2wsh_op_true = fuzzed_data_provider.ConsumeBool();
tx_mut.nVersion = fuzzed_data_provider.ConsumeBool() ?
CTransaction::CURRENT_VERSION :
fuzzed_data_provider.ConsumeIntegral<int32_t>();
fuzzed_data_provider.ConsumeIntegral<uint32_t>();
tx_mut.nLockTime = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
const auto num_in = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, max_num_in);
const auto num_out = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, max_num_out);

View File

@@ -92,7 +92,7 @@ void static RandomScript(CScript &script) {
void static RandomTransaction(CMutableTransaction& tx, bool fSingle)
{
tx.nVersion = int(InsecureRand32());
tx.nVersion = InsecureRand32();
tx.vin.clear();
tx.vout.clear();
tx.nLockTime = (InsecureRandBool()) ? InsecureRand32() : 0;

View File

@@ -780,7 +780,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
CheckIsStandard(t);
// Disallowed nVersion
t.nVersion = -1;
t.nVersion = std::numeric_limits<uint32_t>::max();
CheckIsNotStandard(t, "version");
t.nVersion = 0;