@@ -37,14 +37,22 @@ While this BIP is active, all blocks must set the nVersion header top 3 bits to
3737=== Reference implementation ===
3838
3939<pre>
40+ // Check if Segregated Witness is Locked In
41+ bool IsWitnessLockedIn(const CBlockIndex* pindexPrev, const Consensus::Params& params)
42+ {
43+ LOCK(cs_main);
44+ return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == THRESHOLD_LOCKED_IN);
45+ }
46+
4047// BIP148 mandatory segwit signalling.
4148int64_t nMedianTimePast = pindex->GetMedianTimePast();
4249if ( (nMedianTimePast >= 1501545600) && // Tue 01 Aug 2017 00:00:00 UTC
4350 (nMedianTimePast <= 1510704000) && // Wed 15 Nov 2017 00:00:00 UTC
44- (!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus())) ) // Segwit is not active
51+ (!IsWitnessLockedIn(pindex->pprev, chainparams.GetConsensus()) && // Segwit is not locked in
52+ !IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus())) ) // and is not active.
4553{
46- bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS; // BIP9 bit set
47- bool fSegbit = (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) != 0; // segwit bit set
54+ bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS;
55+ bool fSegbit = (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) != 0;
4856 if (!(fVersionBits && fSegbit)) {
4957 return state.DoS(0, error("ConnectBlock(): relayed block must signal for segwit, please upgrade"), REJECT_INVALID, "bad-no-segwit");
5058 }
0 commit comments