Bitcoin Core  27.99.0
P2P Digital Currency
params.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2022 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 <uint256.h>
10 
11 #include <chrono>
12 #include <limits>
13 #include <map>
14 #include <vector>
15 
16 namespace Consensus {
17 
22 enum BuriedDeployment : int16_t {
23  // buried deployments get negative values to avoid overlap with DeploymentPos
24  DEPLOYMENT_HEIGHTINCB = std::numeric_limits<int16_t>::min(),
29 };
30 constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_SEGWIT; }
31 
32 enum DeploymentPos : uint16_t {
34  DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342)
35  // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
37 };
38 constexpr bool ValidDeployment(DeploymentPos dep) { return dep < MAX_VERSION_BITS_DEPLOYMENTS; }
39 
45  int bit{28};
55 
57  static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
58 
63  static constexpr int64_t ALWAYS_ACTIVE = -1;
64 
68  static constexpr int64_t NEVER_ACTIVE = -2;
69 };
70 
74 struct Params {
83  std::map<uint256, uint32_t> script_flag_exceptions;
92  int CSVHeight;
114  std::chrono::seconds PowTargetSpacing() const
115  {
116  return std::chrono::seconds{nPowTargetSpacing};
117  }
123 
128  bool signet_blocks{false};
129  std::vector<uint8_t> signet_challenge;
130 
132  {
133  switch (dep) {
135  return BIP34Height;
136  case DEPLOYMENT_CLTV:
137  return BIP65Height;
138  case DEPLOYMENT_DERSIG:
139  return BIP66Height;
140  case DEPLOYMENT_CSV:
141  return CSVHeight;
142  case DEPLOYMENT_SEGWIT:
143  return SegwitHeight;
144  } // no default case, so the compiler can warn about missing cases
145  return std::numeric_limits<int>::max();
146  }
147 };
148 
149 } // namespace Consensus
150 
151 #endif // BITCOIN_CONSENSUS_PARAMS_H
256-bit opaque blob.
Definition: uint256.h:106
Transaction validation functions.
constexpr bool ValidDeployment(BuriedDeployment dep)
Definition: params.h:30
DeploymentPos
Definition: params.h:32
@ DEPLOYMENT_TAPROOT
Definition: params.h:34
@ DEPLOYMENT_TESTDUMMY
Definition: params.h:33
@ MAX_VERSION_BITS_DEPLOYMENTS
Definition: params.h:36
BuriedDeployment
A buried deployment is one where the height of the activation has been hardcoded into the client impl...
Definition: params.h:22
@ DEPLOYMENT_DERSIG
Definition: params.h:26
@ DEPLOYMENT_CSV
Definition: params.h:27
@ DEPLOYMENT_SEGWIT
Definition: params.h:28
@ DEPLOYMENT_HEIGHTINCB
Definition: params.h:24
@ DEPLOYMENT_CLTV
Definition: params.h:25
Struct for each individual consensus rule change using BIP9.
Definition: params.h:43
int min_activation_height
If lock in occurs, delay activation until at least this block height.
Definition: params.h:54
int bit
Bit position to select the particular bit in nVersion.
Definition: params.h:45
static constexpr int64_t ALWAYS_ACTIVE
Special value for nStartTime indicating that the deployment is always active.
Definition: params.h:63
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
Definition: params.h:68
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
Definition: params.h:49
static constexpr int64_t NO_TIMEOUT
Constant for nTimeout very far in the future.
Definition: params.h:57
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Definition: params.h:47
Parameters that influence chain consensus.
Definition: params.h:74
int BIP65Height
Block height at which BIP65 becomes active.
Definition: params.h:88
int CSVHeight
Block height at which CSV (BIP68, BIP112 and BIP113) becomes active.
Definition: params.h:92
uint256 BIP34Hash
Definition: params.h:86
uint32_t nMinerConfirmationWindow
Definition: params.h:106
uint256 defaultAssumeValid
By default assume that the signatures in ancestors of this block are valid.
Definition: params.h:122
std::map< uint256, uint32_t > script_flag_exceptions
Hashes of blocks that.
Definition: params.h:83
std::vector< uint8_t > signet_challenge
Definition: params.h:129
int64_t DifficultyAdjustmentInterval() const
Definition: params.h:118
bool signet_blocks
If true, witness commitments contain a payload equal to a Bitcoin Script solution to the signet chall...
Definition: params.h:128
int SegwitHeight
Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
Definition: params.h:96
int BIP34Height
Block height and hash at which BIP34 becomes active.
Definition: params.h:85
int nSubsidyHalvingInterval
Definition: params.h:76
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
Definition: params.h:107
uint256 hashGenesisBlock
Definition: params.h:75
int MinBIP9WarningHeight
Don't warn about unknown BIP 9 activations below this height.
Definition: params.h:99
bool fPowNoRetargeting
Definition: params.h:111
uint256 nMinimumChainWork
The best chain should have at least this much work.
Definition: params.h:120
uint32_t nRuleChangeActivationThreshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,...
Definition: params.h:105
int64_t nPowTargetTimespan
Definition: params.h:113
int BIP66Height
Block height at which BIP66 becomes active.
Definition: params.h:90
uint256 powLimit
Proof of work parameters.
Definition: params.h:109
int DeploymentHeight(BuriedDeployment dep) const
Definition: params.h:131
int64_t nPowTargetSpacing
Definition: params.h:112
std::chrono::seconds PowTargetSpacing() const
Definition: params.h:114
bool fPowAllowMinDifficultyBlocks
Definition: params.h:110