Bitcoin Core  31.0.0
P2P Digital Currency
params.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-present The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_CONSENSUS_PARAMS_H
7 #define BITCOIN_CONSENSUS_PARAMS_H
8 
9 #include <script/verify_flags.h>
10 #include <uint256.h>
11 
12 #include <array>
13 #include <chrono>
14 #include <limits>
15 #include <map>
16 #include <vector>
17 
18 namespace Consensus {
19 
24 enum BuriedDeployment : int16_t {
25  // buried deployments get negative values to avoid overlap with DeploymentPos
26  DEPLOYMENT_HEIGHTINCB = std::numeric_limits<int16_t>::min(),
31 };
32 constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_SEGWIT; }
33 
34 enum DeploymentPos : uint16_t {
36  DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342)
37  // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
39 };
40 constexpr bool ValidDeployment(DeploymentPos dep) { return dep < MAX_VERSION_BITS_DEPLOYMENTS; }
41 
47  int bit{28};
58  uint32_t period{2016};
64  uint32_t threshold{1916};
65 
67  static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
68 
73  static constexpr int64_t ALWAYS_ACTIVE = -1;
74 
78  static constexpr int64_t NEVER_ACTIVE = -2;
79 };
80 
84 struct Params {
93  std::map<uint256, script_verify_flags> script_flag_exceptions;
110  std::array<BIP9Deployment,MAX_VERSION_BITS_DEPLOYMENTS> vDeployments;
122  std::chrono::seconds PowTargetSpacing() const
123  {
124  return std::chrono::seconds{nPowTargetSpacing};
125  }
131 
136  bool signet_blocks{false};
137  std::vector<uint8_t> signet_challenge;
138 
140  {
141  switch (dep) {
143  return BIP34Height;
144  case DEPLOYMENT_CLTV:
145  return BIP65Height;
146  case DEPLOYMENT_DERSIG:
147  return BIP66Height;
148  case DEPLOYMENT_CSV:
149  return CSVHeight;
150  case DEPLOYMENT_SEGWIT:
151  return SegwitHeight;
152  } // no default case, so the compiler can warn about missing cases
153  return std::numeric_limits<int>::max();
154  }
155 };
156 
157 } // namespace Consensus
158 
159 #endif // BITCOIN_CONSENSUS_PARAMS_H
static constexpr int64_t NO_TIMEOUT
Constant for nTimeout very far in the future.
Definition: params.h:67
uint32_t threshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period...
Definition: params.h:64
int min_activation_height
If lock in occurs, delay activation until at least this block height.
Definition: params.h:56
std::array< BIP9Deployment, MAX_VERSION_BITS_DEPLOYMENTS > vDeployments
Definition: params.h:110
uint256 BIP34Hash
Definition: params.h:96
int64_t nPowTargetTimespan
Definition: params.h:121
bool fPowNoRetargeting
Definition: params.h:119
DeploymentPos
Definition: params.h:34
bool fPowAllowMinDifficultyBlocks
Definition: params.h:113
static constexpr int64_t ALWAYS_ACTIVE
Special value for nStartTime indicating that the deployment is always active.
Definition: params.h:73
int BIP66Height
Block height at which BIP66 becomes active.
Definition: params.h:100
uint32_t period
Period of blocks to check signalling in (usually retarget period, ie params.DifficultyAdjustmentInter...
Definition: params.h:58
int CSVHeight
Block height at which CSV (BIP68, BIP112 and BIP113) becomes active.
Definition: params.h:102
Transaction validation functions.
int nSubsidyHalvingInterval
Definition: params.h:86
uint256 powLimit
Proof of work parameters.
Definition: params.h:112
std::map< uint256, script_verify_flags > script_flag_exceptions
Hashes of blocks that.
Definition: params.h:93
Struct for each individual consensus rule change using BIP9.
Definition: params.h:45
int DeploymentHeight(BuriedDeployment dep) const
Definition: params.h:139
int BIP34Height
Block height and hash at which BIP34 becomes active.
Definition: params.h:95
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Definition: params.h:49
int64_t nPowTargetSpacing
Definition: params.h:120
bool signet_blocks
If true, witness commitments contain a payload equal to a Bitcoin Script solution to the signet chall...
Definition: params.h:136
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
Definition: params.h:78
Parameters that influence chain consensus.
Definition: params.h:84
std::chrono::seconds PowTargetSpacing() const
Definition: params.h:122
int BIP65Height
Block height at which BIP65 becomes active.
Definition: params.h:98
int64_t DifficultyAdjustmentInterval() const
Definition: params.h:126
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
Definition: params.h:51
256-bit opaque blob.
Definition: uint256.h:195
uint256 nMinimumChainWork
The best chain should have at least this much work.
Definition: params.h:128
bool enforce_BIP94
Enforce BIP94 timewarp attack mitigation.
Definition: params.h:118
uint256 defaultAssumeValid
By default assume that the signatures in ancestors of this block are valid.
Definition: params.h:130
std::vector< uint8_t > signet_challenge
Definition: params.h:137
int MinBIP9WarningHeight
Don&#39;t warn about unknown BIP 9 activations below this height.
Definition: params.h:109
int SegwitHeight
Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
Definition: params.h:106
int bit
Bit position to select the particular bit in nVersion.
Definition: params.h:47
BuriedDeployment
A buried deployment is one where the height of the activation has been hardcoded into the client impl...
Definition: params.h:24
constexpr bool ValidDeployment(BuriedDeployment dep)
Definition: params.h:32
uint256 hashGenesisBlock
Definition: params.h:85