static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, const uint256& nNonce, const std::vector<unsigned char>& nSolution, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
// To create a genesis block for a new chain which is Overwintered:
- // txNew.nVersion = 3
+ // txNew.nVersion = OVERWINTER_TX_VERSION
// txNew.fOverwintered = true
// txNew.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID
// txNew.nExpiryHeight = <default value>
mtx.vout[0].nValue = 0;
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
CTransaction tx {mtx};
GetBlockSubsidy(1, Params().GetConsensus())/5,
Params().GetFoundersRewardScriptAtHeight(1)));
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
CTransaction tx {mtx};
GetBlockSubsidy(1, Params().GetConsensus())/5,
Params().GetFoundersRewardScriptAtHeight(1)));
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
CTransaction tx {mtx};
TEST(checktransaction_tests, OverwinterConstructors) {
CMutableTransaction mtx;
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nExpiryHeight = 20;
TEST(checktransaction_tests, OverwinterSerialization) {
CMutableTransaction mtx;
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nExpiryHeight = 99;
CMutableTransaction mtx = GetValidTransaction();
mtx.vjoinsplit.resize(0);
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nExpiryHeight = 0;
CTransaction tx(mtx);
CMutableTransaction mtx = GetValidTransaction();
mtx.vjoinsplit.resize(0);
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nExpiryHeight = 0;
CMutableTransaction mtx = GetValidTransaction();
mtx.vjoinsplit.resize(0);
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nExpiryHeight = 0;
mtx.nVersionGroupId = 0x12345678;
CMutableTransaction mtx = GetValidTransaction();
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nExpiryHeight = 0;
CMutableTransaction mtx = GetValidTransaction();
mtx.fOverwintered = false;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nExpiryHeight = 0;
CMutableTransaction mtx = GetValidTransaction();
mtx.vjoinsplit.resize(0); // no joinsplits
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nExpiryHeight = 0;
CValidationState state1;
if (isOverwintered) {
mtx.fOverwintered = true;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
// Expiry height is not set. Only fields required for a parser to treat as a valid Overwinter V3 tx.
// TODO: In future, when moving from Overwinter to Sapling, it will be useful
#include "zcash/JoinSplit.hpp"
#include "zcash/Proof.hpp"
+// Overwinter transaction version
+static const int32_t OVERWINTER_TX_VERSION = 3;
+static_assert(OVERWINTER_TX_VERSION >= OVERWINTER_MIN_TX_VERSION,
+ "Overwinter tx version must not be lower than minimum");
+static_assert(OVERWINTER_TX_VERSION <= OVERWINTER_MAX_TX_VERSION,
+ "Overwinter tx version must not be higher than maximum");
+
// Sapling transaction version
static const int32_t SAPLING_TX_VERSION = 4;
static_assert(SAPLING_TX_VERSION >= SAPLING_MIN_TX_VERSION,
READWRITE(*const_cast<uint32_t*>(&this->nVersionGroupId));
}
- bool isOverwinterV3 = fOverwintered &&
- nVersionGroupId == OVERWINTER_VERSION_GROUP_ID &&
- nVersion == 3;
+ bool isOverwinterV3 =
+ fOverwintered &&
+ nVersionGroupId == OVERWINTER_VERSION_GROUP_ID &&
+ nVersion == OVERWINTER_TX_VERSION;
bool isSaplingV4 =
fOverwintered &&
nVersionGroupId == SAPLING_VERSION_GROUP_ID &&
READWRITE(nVersionGroupId);
}
- bool isOverwinterV3 = fOverwintered &&
- nVersionGroupId == OVERWINTER_VERSION_GROUP_ID &&
- nVersion == 3;
+ bool isOverwinterV3 =
+ fOverwintered &&
+ nVersionGroupId == OVERWINTER_VERSION_GROUP_ID &&
+ nVersion == OVERWINTER_TX_VERSION;
bool isSaplingV4 =
fOverwintered &&
nVersionGroupId == SAPLING_VERSION_GROUP_ID &&
CMutableTransaction mtx;
mtx.fOverwintered = true;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
test_simple_joinsplit_invalidity(NetworkUpgradeInfo[Consensus::UPGRADE_OVERWINTER].nBranchId, mtx);
uint32_t consensusBranchId = NetworkUpgradeInfo[Consensus::UPGRADE_OVERWINTER].nBranchId;
CMutableTransaction mtx;
mtx.fOverwintered = true;
- mtx.nVersion = 3;
+ mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
CKey key;
CMutableTransaction spending_tx;
spending_tx.fOverwintered = true;
- spending_tx.nVersion = 3;
+ spending_tx.nVersion = OVERWINTER_TX_VERSION;
spending_tx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
auto input_hash = orig_tx.GetHash();