|
|
@ -3276,12 +3276,18 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn |
|
|
|
const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; |
|
|
|
const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; |
|
|
|
const Consensus::Params& consensusParams = Params().GetConsensus(); |
|
|
|
const Consensus::Params& consensusParams = Params().GetConsensus(); |
|
|
|
|
|
|
|
|
|
|
|
// Check that all transactions are finalized
|
|
|
|
// Start enforcing BIP113 (Median Time Past) using versionbits logic.
|
|
|
|
BOOST_FOREACH(const CTransaction& tx, block.vtx) { |
|
|
|
|
|
|
|
int nLockTimeFlags = 0; |
|
|
|
int nLockTimeFlags = 0; |
|
|
|
|
|
|
|
if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV, versionbitscache) == THRESHOLD_ACTIVE) { |
|
|
|
|
|
|
|
nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) |
|
|
|
int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) |
|
|
|
? pindexPrev->GetMedianTimePast() |
|
|
|
? pindexPrev->GetMedianTimePast() |
|
|
|
: block.GetBlockTime(); |
|
|
|
: block.GetBlockTime(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check that all transactions are finalized
|
|
|
|
|
|
|
|
BOOST_FOREACH(const CTransaction& tx, block.vtx) { |
|
|
|
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) { |
|
|
|
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) { |
|
|
|
return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction"); |
|
|
|
return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction"); |
|
|
|
} |
|
|
|
} |
|
|
|