Komod-tx functions

This commit is contained in:
jl777
2018-12-29 01:37:53 -11:00
parent cd1dc554ba
commit c10c7d3309
2 changed files with 32 additions and 1 deletions

View File

@@ -177,6 +177,31 @@ static void RegisterLoad(const std::string& strInput)
RegisterSetJson(key, valStr);
}
// Set default values of new CMutableTransaction based on consensus rules at given height.
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight)
{
CMutableTransaction mtx;
bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER);
if (isOverwintered) {
mtx.fOverwintered = true;
mtx.nExpiryHeight = nHeight + 60;
if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) {
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtx.nVersion = SAPLING_TX_VERSION;
} else {
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
mtx.nVersion = OVERWINTER_TX_VERSION;
mtx.nExpiryHeight = std::min(
mtx.nExpiryHeight,
static_cast<uint32_t>(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1));
}
}
return mtx;
}
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
{
int64_t newVersion = atoi64(cmdVal);