Move `CurrentTxVersionInfo` into a new file
Don't compile it for `zcash_script`.
This commit is contained in:
parent
c4b2ef7c4e
commit
ae9266a1cd
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue