Add contextual check to main.cpp

Reject transactions with nonzero vpub_old after NU4
This commit is contained in:
therealyingtong 2020-05-12 10:43:18 +08:00 committed by therealyingtong
parent 552482a404
commit 01cdea54ee
1 changed files with 10 additions and 0 deletions

View File

@ -792,6 +792,7 @@ bool ContextualCheckTransaction(
bool saplingActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_SAPLING);
bool isSprout = !overwinterActive;
bool heartwoodActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_HEARTWOOD);
bool canopyActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY);
// If Sprout rules apply, reject transactions which are intended for Overwinter and beyond
if (isSprout && tx.fOverwintered) {
@ -936,6 +937,15 @@ bool ContextualCheckTransaction(
}
}
// Rules that apply to Canopy or later:
if (canopyActive) {
for (const JSDescription& joinsplit : tx.vJoinSplit) {
if (joinsplit.vpub_old > 0) {
return state.DoS(DOS_LEVEL_BLOCK, error("ContextualCheckTransaction(): joinsplit.vpub_old nonzero"), REJECT_INVALID, "bad-txns-vpub_old-nonzero");
}
}
}
auto consensusBranchId = CurrentEpochBranchId(nHeight, chainparams.GetConsensus());
auto prevConsensusBranchId = PrevEpochBranchId(consensusBranchId, chainparams.GetConsensus());
uint256 dataToBeSigned;