|
|
|
@ -1725,6 +1725,15 @@ public:
|
|
|
|
|
// Protected by cs_main
|
|
|
|
|
static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS];
|
|
|
|
|
|
|
|
|
|
// 0.13.0 was shipped with a segwit deployment defined for testnet, but not for
|
|
|
|
|
// mainnet. We no longer need to support disabling the segwit deployment
|
|
|
|
|
// except for testing purposes, due to limitations of the functional test
|
|
|
|
|
// environment. See test/functional/p2p-segwit.py.
|
|
|
|
|
static bool IsScriptWitnessEnabled(const Consensus::Params& params)
|
|
|
|
|
{
|
|
|
|
|
return params.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& consensusparams) {
|
|
|
|
|
AssertLockHeld(cs_main);
|
|
|
|
|
|
|
|
|
@ -1742,6 +1751,12 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
|
|
|
|
|
flags |= SCRIPT_VERIFY_P2SH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enforce WITNESS rules whenever P2SH is in effect (and the segwit
|
|
|
|
|
// deployment is defined).
|
|
|
|
|
if (flags & SCRIPT_VERIFY_P2SH && IsScriptWitnessEnabled(consensusparams)) {
|
|
|
|
|
flags |= SCRIPT_VERIFY_WITNESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Start enforcing the DERSIG (BIP66) rule
|
|
|
|
|
if (pindex->nHeight >= consensusparams.BIP66Height) {
|
|
|
|
|
flags |= SCRIPT_VERIFY_DERSIG;
|
|
|
|
@ -1757,11 +1772,6 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
|
|
|
|
|
flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
@ -4107,6 +4117,9 @@ bool CChainState::RewindBlockIndex(const CChainParams& params)
|
|
|
|
|
|
|
|
|
|
int nHeight = 1;
|
|
|
|
|
while (nHeight <= chainActive.Height()) {
|
|
|
|
|
// Although SCRIPT_VERIFY_WITNESS is now generally enforced on all
|
|
|
|
|
// blocks in ConnectBlock, we don't need to go back and
|
|
|
|
|
// re-download/re-verify blocks from before segwit actually activated.
|
|
|
|
|
if (IsWitnessEnabled(chainActive[nHeight - 1], params.GetConsensus()) && !(chainActive[nHeight]->nStatus & BLOCK_OPT_WITNESS)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|