Expire Overwinter transactions before the Sapling activation height

This commit is contained in:
Jack Grigg
2018-05-03 12:27:56 +01:00
parent dc889d7f52
commit fa70084c87
4 changed files with 7 additions and 18 deletions

View File

@@ -31,6 +31,7 @@
#include "wallet/asyncrpcoperation_sendmany.h"
#include "wallet/asyncrpcoperation_shieldcoinbase.h"
#include <algorithm>
#include <sstream>
#include <boost/algorithm/string/replace.hpp>
@@ -6078,17 +6079,18 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para
bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER);
if (isOverwintered) {
mtx.fOverwintered = true;
mtx.nExpiryHeight = nHeight + expiryDelta;
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));
}
// 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
// to set the expiry height to: min(activation_height - 1, default_expiry_height)
}
return mtx;
}