diff --git a/src/Makefile.am b/src/Makefile.am index 034856579..9477cd033 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 8239cfc98..2263ab91b 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.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 - }; - } -} diff --git a/src/primitives/tx_version_info.cpp b/src/primitives/tx_version_info.cpp new file mode 100644 index 000000000..80b59ac10 --- /dev/null +++ b/src/primitives/tx_version_info.cpp @@ -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 + }; + } +}