@@ -37,14 +37,22 @@ While this BIP is active, all blocks must set the nVersion header top 3 bits to
37
37
=== Reference implementation ===
38
38
39
39
<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
+
40
47
// BIP148 mandatory segwit signalling.
41
48
int64_t nMedianTimePast = pindex->GetMedianTimePast();
42
49
if ( (nMedianTimePast >= 1501545600) && // Tue 01 Aug 2017 00:00:00 UTC
43
50
(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.
45
53
{
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;
48
56
if (!(fVersionBits && fSegbit)) {
49
57
return state.DoS(0, error("ConnectBlock(): relayed block must signal for segwit, please upgrade"), REJECT_INVALID, "bad-no-segwit");
50
58
}
0 commit comments