Skip to content

Commit 95749a5

Browse files
committed
Separate NULLDUMMY enforcement from SEGWIT enforcement
This is in preparation for enforcing SCRIPT_VERIFY_WITNESS from the genesis block.
1 parent ce65018 commit 95749a5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/validation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,9 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
17601760
// Start enforcing WITNESS rules using versionbits logic.
17611761
if (IsWitnessEnabled(pindex->pprev, consensusparams)) {
17621762
flags |= SCRIPT_VERIFY_WITNESS;
1763+
}
1764+
1765+
if (IsNullDummyEnabled(pindex->pprev, consensusparams)) {
17631766
flags |= SCRIPT_VERIFY_NULLDUMMY;
17641767
}
17651768

@@ -3106,6 +3109,12 @@ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& pa
31063109
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE);
31073110
}
31083111

3112+
bool IsNullDummyEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params)
3113+
{
3114+
LOCK(cs_main);
3115+
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE);
3116+
}
3117+
31093118
// Compute at which vout of the block's coinbase transaction the witness
31103119
// commitment occurs, or -1 if not found.
31113120
static int GetWitnessCommitmentIndex(const CBlock& block)

src/validation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams,
411411
/** Check whether witness commitments are required for block. */
412412
bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params);
413413

414+
/** Check whether NULLDUMMY (BIP 147) has activated. */
415+
bool IsNullDummyEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params);
416+
414417
/** When there are blocks in the active chain with missing data, rewind the chainstate and remove them from the block index */
415418
bool RewindBlockIndex(const CChainParams& params);
416419

0 commit comments

Comments
 (0)