aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2020-07-03 04:01:23 +1000
committerAnthony Towns <aj@erisian.com.au>2021-06-30 08:18:58 +1000
commitde55304f6e7a8b607e6b3fc7436de50910747b0c (patch)
treece1cb7ee0bcad78cb327650e0c4cb5e51b28074a /src/validation.cpp
parent2b0d291da8f479739ff394dd92801da8c40b9f8e (diff)
[refactor] Add versionbits deployments to deploymentstatus.h
Adds support for versionbits deployments to DeploymentEnabled, DeploymentActiveAfter and DeploymentActiveAt. Also moves versionbitscache from validation to deploymentstatus.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index b69faa54eb..782a6cd56d 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -684,9 +684,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
}
// Check for non-standard pay-to-script-hash in inputs
- const auto& params = args.m_chainparams.GetConsensus();
- auto taproot_state = VersionBitsState(m_active_chainstate.m_chain.Tip(), params, Consensus::DEPLOYMENT_TAPROOT, versionbitscache);
- if (fRequireStandard && !AreInputsStandard(tx, m_view, taproot_state == ThresholdState::ACTIVE)) {
+ const bool taproot_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), args.m_chainparams.GetConsensus(), Consensus::DEPLOYMENT_TAPROOT);
+ if (fRequireStandard && !AreInputsStandard(tx, m_view, taproot_active)) {
return state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs");
}
@@ -1607,8 +1606,6 @@ void StopScriptCheckWorkerThreads()
scriptcheckqueue.StopWorkerThreads();
}
-VersionBitsCache versionbitscache;
-
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params)
{
int32_t nVersion = VERSIONBITS_TOP_BITS;
@@ -1687,8 +1684,8 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
}
- // Start enforcing Taproot using versionbits logic.
- if (VersionBitsState(pindex->pprev, consensusparams, Consensus::DEPLOYMENT_TAPROOT, versionbitscache) == ThresholdState::ACTIVE) {
+ // Enforce Taproot (BIP340-BIP342)
+ if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_TAPROOT)) {
flags |= SCRIPT_VERIFY_TAPROOT;
}