Move `CurrentTxVersionInfo` into a new file

Don't compile it for `zcash_script`.
This commit is contained in:
Janito Vaqueiro Ferreira Filho 2021-10-05 21:27:33 +00:00 committed by Jack Grigg
parent c4b2ef7c4e
commit ae9266a1cd
3 changed files with 50 additions and 42 deletions

View File

@ -393,6 +393,7 @@ libbitcoin_common_a_SOURCES = \
netbase.cpp \
primitives/block.cpp \
primitives/transaction.cpp \
primitives/tx_version_info.cpp \
proof_verifier.cpp \
protocol.cpp \
pubkey.cpp \
@ -558,6 +559,7 @@ libzcash_script_la_SOURCES = \
crypto/sha512.cpp \
hash.cpp \
primitives/transaction.cpp \
primitives/tx_version_info.cpp \
pubkey.cpp \
script/zcash_script.cpp \
script/interpreter.cpp \

View File

@ -425,45 +425,3 @@ std::string CTransaction::ToString() const
str += " " + vout[i].ToString() + "\n";
return str;
}
/**
* Returns the most recent supported transaction version and version group id,
* as of the specified activation height and active features.
*/
TxVersionInfo CurrentTxVersionInfo(
const Consensus::Params& consensus,
int nHeight,
bool requireSprout)
{
if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_ZFUTURE)) {
return {
.fOverwintered = true,
.nVersionGroupId = ZFUTURE_VERSION_GROUP_ID,
.nVersion = ZFUTURE_TX_VERSION
};
} else if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_NU5) && !requireSprout) {
return {
.fOverwintered = true,
.nVersionGroupId = ZIP225_VERSION_GROUP_ID,
.nVersion = ZIP225_TX_VERSION
};
} else if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_SAPLING)) {
return {
.fOverwintered = true,
.nVersionGroupId = SAPLING_VERSION_GROUP_ID,
.nVersion = SAPLING_TX_VERSION
};
} else if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_OVERWINTER)) {
return {
.fOverwintered = true,
.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID,
.nVersion = OVERWINTER_TX_VERSION
};
} else {
return {
.fOverwintered = false,
.nVersionGroupId = 0,
.nVersion = CTransaction::SPROUT_MIN_CURRENT_VERSION
};
}
}

View File

@ -0,0 +1,48 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#include "primitives/transaction.h"
/**
* Returns the most recent supported transaction version and version group id,
* as of the specified activation height and active features.
*/
TxVersionInfo CurrentTxVersionInfo(
const Consensus::Params& consensus,
int nHeight,
bool requireSprout)
{
if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_ZFUTURE)) {
return {
.fOverwintered = true,
.nVersionGroupId = ZFUTURE_VERSION_GROUP_ID,
.nVersion = ZFUTURE_TX_VERSION
};
} else if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_NU5) && !requireSprout) {
return {
.fOverwintered = true,
.nVersionGroupId = ZIP225_VERSION_GROUP_ID,
.nVersion = ZIP225_TX_VERSION
};
} else if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_SAPLING)) {
return {
.fOverwintered = true,
.nVersionGroupId = SAPLING_VERSION_GROUP_ID,
.nVersion = SAPLING_TX_VERSION
};
} else if (consensus.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_OVERWINTER)) {
return {
.fOverwintered = true,
.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID,
.nVersion = OVERWINTER_TX_VERSION
};
} else {
return {
.fOverwintered = false,
.nVersionGroupId = 0,
.nVersion = CTransaction::SPROUT_MIN_CURRENT_VERSION
};
}
}