mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic
Based on the earlier BIP66 soft-fork logic implemented by Pieter
Wuille's 5a47811da5
This commit is contained in:
14
src/main.cpp
14
src/main.cpp
@@ -1740,11 +1740,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
|
||||
unsigned int flags = fStrictPayToScriptHash ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE;
|
||||
|
||||
// Start enforcing the DERSIG (BIP66) rules, for block.nVersion=3 blocks, when 75% of the network has upgraded:
|
||||
// Start enforcing the DERSIG (BIP66) rules, for block.nVersion=3 blocks,
|
||||
// when 75% of the network has upgraded:
|
||||
if (block.nVersion >= 3 && IsSuperMajority(3, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
|
||||
flags |= SCRIPT_VERIFY_DERSIG;
|
||||
}
|
||||
|
||||
// Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
|
||||
// blocks, when 75% of the network has upgraded:
|
||||
if (block.nVersion >= 4 && IsSuperMajority(4, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
|
||||
flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
|
||||
}
|
||||
|
||||
CBlockUndo blockundo;
|
||||
|
||||
CCheckQueueControl<CScriptCheck> control(fScriptChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL);
|
||||
@@ -2684,6 +2691,11 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
return state.Invalid(error("%s : rejected nVersion=2 block", __func__),
|
||||
REJECT_OBSOLETE, "bad-version");
|
||||
|
||||
// Reject block.nVersion=3 blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
if (block.nVersion < 4 && IsSuperMajority(4, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
|
||||
return state.Invalid(error("%s : rejected nVersion=3 block", __func__),
|
||||
REJECT_OBSOLETE, "bad-version");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user