MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / GetBlockScriptFlags

Function GetBlockScriptFlags

src/validation.cpp:2256–2295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2254}
2255
2256script_verify_flags GetBlockScriptFlags(const CBlockIndex& block_index, const ChainstateManager& chainman)
2257{
2258 const Consensus::Params& consensusparams = chainman.GetConsensus();
2259
2260 // BIP16 didn't become active until Apr 1 2012 (on mainnet, and
2261 // retroactively applied to testnet)
2262 // However, only one historical block violated the P2SH rules (on both
2263 // mainnet and testnet).
2264 // Similarly, only one historical block violated the TAPROOT rules on
2265 // mainnet.
2266 // For simplicity, always leave P2SH+WITNESS+TAPROOT on except for the two
2267 // violating blocks.
2268 script_verify_flags flags{SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_TAPROOT};
2269 const auto it{consensusparams.script_flag_exceptions.find(*Assert(block_index.phashBlock))};
2270 if (it != consensusparams.script_flag_exceptions.end()) {
2271 flags = it->second;
2272 }
2273
2274 // Enforce the DERSIG (BIP66) rule
2275 if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_DERSIG)) {
2276 flags |= SCRIPT_VERIFY_DERSIG;
2277 }
2278
2279 // Enforce CHECKLOCKTIMEVERIFY (BIP65)
2280 if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_CLTV)) {
2281 flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
2282 }
2283
2284 // Enforce CHECKSEQUENCEVERIFY (BIP112)
2285 if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_CSV)) {
2286 flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
2287 }
2288
2289 // Enforce BIP147 NULLDUMMY (activated simultaneously with segwit)
2290 if (DeploymentActiveAt(block_index, chainman, Consensus::DEPLOYMENT_SEGWIT)) {
2291 flags |= SCRIPT_VERIFY_NULLDUMMY;
2292 }
2293
2294 return flags;
2295}
2296
2297
2298/** Apply the effects of this block (with given index) on the UTXO set represented by coins.

Callers 3

ConsensusScriptChecksMethod · 0.85
ConnectBlockMethod · 0.85
getdeploymentinfoFunction · 0.85

Calls 3

findMethod · 0.80
DeploymentActiveAtFunction · 0.70
endMethod · 0.45

Tested by

no test coverage detected