| 1999 | static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_main); |
| 2000 | |
| 2001 | static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& consensusparams) |
| 2002 | { |
| 2003 | unsigned int flags = SCRIPT_VERIFY_NONE; |
| 2004 | |
| 2005 | // BIP16 didn't become active until Apr 1 2012 (on mainnet, and |
| 2006 | // retroactively applied to testnet) |
| 2007 | // However, only one historical block violated the P2SH rules (on both |
| 2008 | // mainnet and testnet), so for simplicity, always leave P2SH |
| 2009 | // on except for the one violating block. |
| 2010 | if (consensusparams.BIP16Exception.IsNull() || // no bip16 exception on this chain |
| 2011 | pindex->phashBlock == nullptr || // this is a new candidate block, eg from TestBlockValidity() |
| 2012 | *pindex->phashBlock != consensusparams.BIP16Exception) // this block isn't the historical exception |
| 2013 | { |
| 2014 | // Enforce WITNESS rules whenever P2SH is in effect |
| 2015 | flags |= SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS; |
| 2016 | } |
| 2017 | |
| 2018 | // Enforce the DERSIG (BIP66) rule |
| 2019 | if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_DERSIG)) { |
| 2020 | flags |= SCRIPT_VERIFY_DERSIG; |
| 2021 | } |
| 2022 | |
| 2023 | // Enforce CHECKLOCKTIMEVERIFY (BIP65) |
| 2024 | if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_CLTV)) { |
| 2025 | flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; |
| 2026 | } |
| 2027 | |
| 2028 | // Enforce CHECKSEQUENCEVERIFY (BIP112) |
| 2029 | if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_CSV)) { |
| 2030 | flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY; |
| 2031 | } |
| 2032 | |
| 2033 | // Enforce Taproot (BIP340-BIP342) |
| 2034 | if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_TAPROOT)) { |
| 2035 | flags |= SCRIPT_VERIFY_TAPROOT; |
| 2036 | } |
| 2037 | |
| 2038 | // Enforce BIP147 NULLDUMMY (activated simultaneously with segwit) |
| 2039 | if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_SEGWIT)) { |
| 2040 | flags |= SCRIPT_VERIFY_NULLDUMMY; |
| 2041 | } |
| 2042 | |
| 2043 | if (DeploymentActiveAfter(pindex->pprev, consensusparams, Consensus::DEPLOYMENT_DYNA_FED)) { |
| 2044 | flags |= SCRIPT_SIGHASH_RANGEPROOF; |
| 2045 | } |
| 2046 | |
| 2047 | if (DeploymentActiveAfter(pindex->pprev, consensusparams, Consensus::DEPLOYMENT_SIMPLICITY)) { |
| 2048 | flags |= SCRIPT_VERIFY_SIMPLICITY; |
| 2049 | } |
| 2050 | |
| 2051 | return flags; |
| 2052 | } |
| 2053 | |
| 2054 | |
| 2055 |
no test coverage detected