mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
Enforce Taproot script flags whenever WITNESS is set
This commit is contained in:
@@ -1581,18 +1581,18 @@ static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_
|
||||
|
||||
static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Consensus::Params& consensusparams)
|
||||
{
|
||||
unsigned int flags = SCRIPT_VERIFY_NONE;
|
||||
|
||||
// BIP16 didn't become active until Apr 1 2012 (on mainnet, and
|
||||
// retroactively applied to testnet)
|
||||
// However, only one historical block violated the P2SH rules (on both
|
||||
// mainnet and testnet), so for simplicity, always leave P2SH
|
||||
// on except for the one violating block.
|
||||
if (consensusparams.BIP16Exception.IsNull() || // no bip16 exception on this chain
|
||||
*Assert(block_index.phashBlock) != consensusparams.BIP16Exception) // this block isn't the historical exception
|
||||
{
|
||||
// Enforce WITNESS rules whenever P2SH is in effect
|
||||
flags |= SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS;
|
||||
// mainnet and testnet).
|
||||
// Similarly, only one historical block violated the TAPROOT rules on
|
||||
// mainnet.
|
||||
// For simplicity, always leave P2SH+WITNESS+TAPROOT on except for the two
|
||||
// violating blocks.
|
||||
uint32_t flags{SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_TAPROOT};
|
||||
const auto it{consensusparams.script_flag_exceptions.find(*Assert(block_index.phashBlock))};
|
||||
if (it != consensusparams.script_flag_exceptions.end()) {
|
||||
flags = it->second;
|
||||
}
|
||||
|
||||
// Enforce the DERSIG (BIP66) rule
|
||||
@@ -1610,11 +1610,6 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Co
|
||||
flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
|
||||
}
|
||||
|
||||
// Enforce Taproot (BIP340-BIP342)
|
||||
if (DeploymentActiveAt(block_index, consensusparams, Consensus::DEPLOYMENT_TAPROOT)) {
|
||||
flags |= SCRIPT_VERIFY_TAPROOT;
|
||||
}
|
||||
|
||||
// Enforce BIP147 NULLDUMMY (activated simultaneously with segwit)
|
||||
if (DeploymentActiveAt(block_index, consensusparams, Consensus::DEPLOYMENT_SEGWIT)) {
|
||||
flags |= SCRIPT_VERIFY_NULLDUMMY;
|
||||
|
||||
Reference in New Issue
Block a user