Branch data Line data Source code
# 1 : : // Copyright (c) 2009-2010 Satoshi Nakamoto # 2 : : // Copyright (c) 2009-2020 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 : : #include <limits> # 11 : : # 12 : : namespace Consensus { # 13 : : # 14 : : enum DeploymentPos # 15 : : { # 16 : : DEPLOYMENT_TESTDUMMY, # 17 : : DEPLOYMENT_TAPROOT, // Deployment of Schnorr/Taproot (BIPs 340-342) # 18 : : // NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp # 19 : : MAX_VERSION_BITS_DEPLOYMENTS # 20 : : }; # 21 : : # 22 : : /** # 23 : : * Struct for each individual consensus rule change using BIP9. # 24 : : */ # 25 : : struct BIP9Deployment { # 26 : : /** Bit position to select the particular bit in nVersion. */ # 27 : : int bit; # 28 : : /** Start MedianTime for version bits miner confirmation. Can be a date in the past */ # 29 : : int64_t nStartTime; # 30 : : /** Timeout/expiry MedianTime for the deployment attempt. */ # 31 : : int64_t nTimeout; # 32 : : /** If lock in occurs, delay activation until at least this block # 33 : : * height. Note that activation will only occur on a retarget # 34 : : * boundary. # 35 : : */ # 36 : : int min_activation_height{0}; # 37 : : # 38 : : /** Constant for nTimeout very far in the future. */ # 39 : : static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max(); # 40 : : # 41 : : /** Special value for nStartTime indicating that the deployment is always active. # 42 : : * This is useful for testing, as it means tests don't need to deal with the activation # 43 : : * process (which takes at least 3 BIP9 intervals). Only tests that specifically test the # 44 : : * behaviour during activation cannot use this. */ # 45 : : static constexpr int64_t ALWAYS_ACTIVE = -1; # 46 : : # 47 : : /** Special value for nStartTime indicating that the deployment is never active. # 48 : : * This is useful for integrating the code changes for a new feature # 49 : : * prior to deploying it on some or all networks. */ # 50 : : static constexpr int64_t NEVER_ACTIVE = -2; # 51 : : }; # 52 : : # 53 : : /** # 54 : : * Parameters that influence chain consensus. # 55 : : */ # 56 : : struct Params { # 57 : : uint256 hashGenesisBlock; # 58 : : int nSubsidyHalvingInterval; # 59 : : /* Block hash that is excepted from BIP16 enforcement */ # 60 : : uint256 BIP16Exception; # 61 : : /** Block height and hash at which BIP34 becomes active */ # 62 : : int BIP34Height; # 63 : : uint256 BIP34Hash; # 64 : : /** Block height at which BIP65 becomes active */ # 65 : : int BIP65Height; # 66 : : /** Block height at which BIP66 becomes active */ # 67 : : int BIP66Height; # 68 : : /** Block height at which CSV (BIP68, BIP112 and BIP113) becomes active */ # 69 : : int CSVHeight; # 70 : : /** Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active. # 71 : : * Note that segwit v0 script rules are enforced on all blocks except the # 72 : : * BIP 16 exception blocks. */ # 73 : : int SegwitHeight; # 74 : : /** Don't warn about unknown BIP 9 activations below this height. # 75 : : * This prevents us from warning about the CSV and segwit activations. */ # 76 : : int MinBIP9WarningHeight; # 77 : : /** # 78 : : * Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period, # 79 : : * (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments. # 80 : : * Examples: 1916 for 95%, 1512 for testchains. # 81 : : */ # 82 : : uint32_t nRuleChangeActivationThreshold; # 83 : : uint32_t nMinerConfirmationWindow; # 84 : : BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]; # 85 : : /** Proof of work parameters */ # 86 : : uint256 powLimit; # 87 : : bool fPowAllowMinDifficultyBlocks; # 88 : : bool fPowNoRetargeting; # 89 : : int64_t nPowTargetSpacing; # 90 : : int64_t nPowTargetTimespan; # 91 : 66313361 : int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; } # 92 : : /** The best chain should have at least this much work */ # 93 : : uint256 nMinimumChainWork; # 94 : : /** By default assume that the signatures in ancestors of this block are valid */ # 95 : : uint256 defaultAssumeValid; # 96 : : # 97 : : /** # 98 : : * If true, witness commitments contain a payload equal to a Bitcoin Script solution # 99 : : * to the signet challenge. See BIP325. # 100 : : */ # 101 : : bool signet_blocks{false}; # 102 : : std::vector<uint8_t> signet_challenge; # 103 : : }; # 104 : : } // namespace Consensus # 105 : : # 106 : : #endif // BITCOIN_CONSENSUS_PARAMS_H