diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-01-19 18:37:21 -0500 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2015-02-01 17:57:38 -0400 |
commit | 773c30d7564882d347ec80c77992a61935f6675a (patch) | |
tree | eac9f501a25520de08e216b43fe693813873f6f6 | |
parent | 18695f08ef1150851b3ff86cdf7bd5870f65e1dd (diff) |
BIP66 changeover logic
-rw-r--r-- | src/main.cpp | 12 | ||||
-rw-r--r-- | src/primitives/block.h | 2 | ||||
-rw-r--r-- | src/script/bitcoinconsensus.h | 1 | ||||
-rw-r--r-- | src/script/standard.h | 1 |
4 files changed, 15 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 8f58547fe5..47138aefe5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1685,6 +1685,11 @@ 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: + if (block.nVersion >= 3 && CBlockIndex::IsSuperMajority(3, pindex->pprev, Params().EnforceBlockUpgradeMajority())) { + flags |= SCRIPT_VERIFY_DERSIG; + } + CBlockUndo blockundo; CCheckQueueControl<CScriptCheck> control(fScriptChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL); @@ -2524,6 +2529,13 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta REJECT_OBSOLETE, "bad-version"); } + // Reject block.nVersion=2 blocks when 95% (75% on testnet) of the network has upgraded: + if (block.nVersion < 3 && CBlockIndex::IsSuperMajority(3, pindexPrev, Params().RejectBlockOutdatedMajority())) + { + return state.Invalid(error("%s : rejected nVersion=2 block", __func__), + REJECT_OBSOLETE, "bad-version"); + } + return true; } diff --git a/src/primitives/block.h b/src/primitives/block.h index a189592539..9c17902e15 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -24,7 +24,7 @@ class CBlockHeader { public: // header - static const int32_t CURRENT_VERSION=2; + static const int32_t CURRENT_VERSION=3; int32_t nVersion; uint256 hashPrevBlock; uint256 hashMerkleRoot; diff --git a/src/script/bitcoinconsensus.h b/src/script/bitcoinconsensus.h index 15e3337a8d..c57d8b3cc5 100644 --- a/src/script/bitcoinconsensus.h +++ b/src/script/bitcoinconsensus.h @@ -46,6 +46,7 @@ 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 }; /// Returns 1 if the input nIn of the serialized transaction pointed to by diff --git a/src/script/standard.h b/src/script/standard.h index c4b82b4c45..3fea6b9ab9 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -45,6 +45,7 @@ static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH; * blocks and we must accept those blocks. */ static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS | + SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_STRICTENC | SCRIPT_VERIFY_MINIMALDATA | SCRIPT_VERIFY_NULLDUMMY | |