Bitcoin Core 31.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-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
10#include <uint256.h>
11
12#include <array>
13#include <chrono>
14#include <cstdint>
15#include <limits>
16#include <map>
17#include <vector>
18
19namespace Consensus {
20
26enum BuriedDeployment : int16_t {
27 // buried deployments get negative values to avoid overlap with DeploymentPos
28 DEPLOYMENT_HEIGHTINCB = std::numeric_limits<int16_t>::min(),
32 // SCRIPT_VERIFY_WITNESS is enforced from genesis, but the check for downloading
33 // missing witness data is not. BIP 147 also relies on hardcoded activation height.
35};
36constexpr bool ValidDeployment(BuriedDeployment dep) { return dep <= DEPLOYMENT_SEGWIT; }
37
38enum DeploymentPos : uint16_t {
40 // NOTE: Also add new deployments to VersionBitsDeploymentInfo in deploymentinfo.cpp
41 // Removing an entry may require bumping MinBIP9WarningHeight.
43};
44constexpr bool ValidDeployment(DeploymentPos dep) { return dep < MAX_VERSION_BITS_DEPLOYMENTS; }
45
51 int bit{28};
62 uint32_t period{2016};
68 uint32_t threshold{1916};
69
71 static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
72
77 static constexpr int64_t ALWAYS_ACTIVE = -1;
78
82 static constexpr int64_t NEVER_ACTIVE = -2;
83};
84
88struct Params {
97 std::map<uint256, script_verify_flags> script_flag_exceptions;
114 std::array<BIP9Deployment,MAX_VERSION_BITS_DEPLOYMENTS> vDeployments;
126 std::chrono::seconds PowTargetSpacing() const
127 {
128 return std::chrono::seconds{nPowTargetSpacing};
129 }
135
140 bool signet_blocks{false};
141 std::vector<uint8_t> signet_challenge;
142
144 {
145 switch (dep) {
147 return BIP34Height;
148 case DEPLOYMENT_CLTV:
149 return BIP65Height;
151 return BIP66Height;
152 case DEPLOYMENT_CSV:
153 return CSVHeight;
155 return SegwitHeight;
156 } // no default case, so the compiler can warn about missing cases
157 return std::numeric_limits<int>::max();
158 }
159};
160
161} // namespace Consensus
162
163#endif // BITCOIN_CONSENSUS_PARAMS_H
256-bit opaque blob.
Definition: uint256.h:196
Transaction validation functions.
constexpr bool ValidDeployment(BuriedDeployment dep)
Definition: params.h:36
DeploymentPos
Definition: params.h:38
@ DEPLOYMENT_TESTDUMMY
Definition: params.h:39
@ MAX_VERSION_BITS_DEPLOYMENTS
Definition: params.h:42
BuriedDeployment
A buried deployment is one where the height of the activation has been hardcoded into the client impl...
Definition: params.h:26
@ DEPLOYMENT_DERSIG
Definition: params.h:30
@ DEPLOYMENT_CSV
Definition: params.h:31
@ DEPLOYMENT_SEGWIT
Definition: params.h:34
@ DEPLOYMENT_HEIGHTINCB
Definition: params.h:28
@ DEPLOYMENT_CLTV
Definition: params.h:29
Struct for each individual consensus rule change using BIP9.
Definition: params.h:49
int min_activation_height
If lock in occurs, delay activation until at least this block height.
Definition: params.h:60
int bit
Bit position to select the particular bit in nVersion.
Definition: params.h:51
static constexpr int64_t ALWAYS_ACTIVE
Special value for nStartTime indicating that the deployment is always active.
Definition: params.h:77
static constexpr int64_t NEVER_ACTIVE
Special value for nStartTime indicating that the deployment is never active.
Definition: params.h:82
uint32_t period
Period of blocks to check signalling in (usually retarget period, ie params.DifficultyAdjustmentInter...
Definition: params.h:62
uint32_t threshold
Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,...
Definition: params.h:68
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
Definition: params.h:55
static constexpr int64_t NO_TIMEOUT
Constant for nTimeout very far in the future.
Definition: params.h:71
int64_t nStartTime
Start MedianTime for version bits miner confirmation.
Definition: params.h:53
Parameters that influence chain consensus.
Definition: params.h:88
bool enforce_BIP94
Enforce BIP94 timewarp attack mitigation.
Definition: params.h:122
int BIP65Height
Block height at which BIP65 becomes active.
Definition: params.h:102
int CSVHeight
Block height at which CSV (BIP68, BIP112 and BIP113) becomes active.
Definition: params.h:106
uint256 BIP34Hash
Definition: params.h:100
uint256 defaultAssumeValid
By default assume that the signatures in ancestors of this block are valid.
Definition: params.h:134
std::vector< uint8_t > signet_challenge
Definition: params.h:141
int64_t DifficultyAdjustmentInterval() const
Definition: params.h:130
bool signet_blocks
If true, witness commitments contain a payload equal to a Bitcoin Script solution to the signet chall...
Definition: params.h:140
int SegwitHeight
Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
Definition: params.h:110
int BIP34Height
Block height and hash at which BIP34 becomes active.
Definition: params.h:99
int nSubsidyHalvingInterval
Definition: params.h:90
std::map< uint256, script_verify_flags > script_flag_exceptions
Hashes of blocks that.
Definition: params.h:97
uint256 hashGenesisBlock
Definition: params.h:89
int MinBIP9WarningHeight
Don't warn about unknown BIP 9 activations below this height.
Definition: params.h:113
bool fPowNoRetargeting
Definition: params.h:123
uint256 nMinimumChainWork
The best chain should have at least this much work.
Definition: params.h:132
int64_t nPowTargetTimespan
Definition: params.h:125
int BIP66Height
Block height at which BIP66 becomes active.
Definition: params.h:104
uint256 powLimit
Proof of work parameters.
Definition: params.h:116
int DeploymentHeight(BuriedDeployment dep) const
Definition: params.h:143
std::array< BIP9Deployment, MAX_VERSION_BITS_DEPLOYMENTS > vDeployments
Definition: params.h:114
int64_t nPowTargetSpacing
Definition: params.h:124
std::chrono::seconds PowTargetSpacing() const
Definition: params.h:126
bool fPowAllowMinDifficultyBlocks
Definition: params.h:117