diff options
author | Suhas Daftuar <sdaftuar@chaincode.com> | 2017-09-12 12:40:29 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2018-04-13 10:35:27 -0400 |
commit | 95749a58364611c997ba9295fb27489e0d7b1d42 (patch) | |
tree | e9c254385c6abd27c1ff919d385f614a236d4beb | |
parent | ce650182f4d9847423202789856e6e5f499151f8 (diff) |
Separate NULLDUMMY enforcement from SEGWIT enforcement
This is in preparation for enforcing SCRIPT_VERIFY_WITNESS from
the genesis block.
-rw-r--r-- | src/validation.cpp | 9 | ||||
-rw-r--r-- | src/validation.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index ac585895e5..6bcc03c305 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1760,6 +1760,9 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens // Start enforcing WITNESS rules using versionbits logic. if (IsWitnessEnabled(pindex->pprev, consensusparams)) { flags |= SCRIPT_VERIFY_WITNESS; + } + + if (IsNullDummyEnabled(pindex->pprev, consensusparams)) { flags |= SCRIPT_VERIFY_NULLDUMMY; } @@ -3106,6 +3109,12 @@ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& pa return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE); } +bool IsNullDummyEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params) +{ + LOCK(cs_main); + return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE); +} + // Compute at which vout of the block's coinbase transaction the witness // commitment occurs, or -1 if not found. static int GetWitnessCommitmentIndex(const CBlock& block) diff --git a/src/validation.h b/src/validation.h index 3668484696..b415a85053 100644 --- a/src/validation.h +++ b/src/validation.h @@ -411,6 +411,9 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, /** Check whether witness commitments are required for block. */ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params); +/** Check whether NULLDUMMY (BIP 147) has activated. */ +bool IsNullDummyEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params); + /** When there are blocks in the active chain with missing data, rewind the chainstate and remove them from the block index */ bool RewindBlockIndex(const CChainParams& params); |