mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 10:19:26 +02:00
Merge pull request #6351
65ef372
Add BIP65 to getblockchaininfo softforks list (Peter Todd)cde7ab2
Add RPC tests for the CHECKLOCKTIMEVERIFY (BIP65) soft-fork (Peter Todd)287f54f
Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic (Peter Todd)
This commit is contained in:
14
src/main.cpp
14
src/main.cpp
@ -1751,11 +1751,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);
|
||||
@ -2702,6 +2709,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;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class CBlockHeader
|
||||
{
|
||||
public:
|
||||
// header
|
||||
static const int32_t CURRENT_VERSION=3;
|
||||
static const int32_t CURRENT_VERSION=4;
|
||||
int32_t nVersion;
|
||||
uint256 hashPrevBlock;
|
||||
uint256 hashMerkleRoot;
|
||||
|
@ -648,6 +648,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||
UniValue softforks(UniValue::VARR);
|
||||
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
|
||||
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
|
||||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
|
||||
obj.push_back(Pair("softforks", softforks));
|
||||
|
||||
if (fPruneMode)
|
||||
|
@ -44,9 +44,10 @@ typedef enum bitcoinconsensus_error_t
|
||||
/** Script verification flags */
|
||||
enum
|
||||
{
|
||||
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
|
||||
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
|
||||
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance
|
||||
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE = 0,
|
||||
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH = (1U << 0), // evaluate P2SH (BIP16) subscripts
|
||||
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG = (1U << 2), // enforce strict DER (BIP66) compliance
|
||||
bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9), // enable CHECKLOCKTIMEVERIFY (BIP65)
|
||||
};
|
||||
|
||||
/// Returns 1 if the input nIn of the serialized transaction pointed to by
|
||||
|
Reference in New Issue
Block a user