Skip to content

Commit 1352c36

Browse files
committed
Stop BIP 148 enforced signalling if SegWit is Locked-In State
1 parent 2a97af8 commit 1352c36

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

bip-0148.mediawiki

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
4148
int64_t nMedianTimePast = pindex->GetMedianTimePast();
4249
if ( (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

Comments
 (0)