Bitcoin Core  21.99.0
P2P Digital Currency
chainparams.h
Go to the documentation of this file.
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_CHAINPARAMS_H
7 #define BITCOIN_CHAINPARAMS_H
8 
9 #include <chainparamsbase.h>
10 #include <consensus/params.h>
11 #include <primitives/block.h>
12 #include <protocol.h>
13 
14 #include <memory>
15 #include <vector>
16 
17 typedef std::map<int, uint256> MapCheckpoints;
18 
21 
22  int GetHeight() const {
23  const auto& final_checkpoint = mapCheckpoints.rbegin();
24  return final_checkpoint->first /* height */;
25  }
26 };
27 
36 
41  const unsigned int nChainTx;
42 };
43 
44 std::ostream& operator<<(std::ostream& o, const AssumeutxoData& aud);
45 
46 using MapAssumeutxo = std::map<int, const AssumeutxoData>;
47 
54 struct ChainTxData {
55  int64_t nTime;
56  int64_t nTxCount;
57  double dTxRate;
58 };
59 
65 {
66 public:
67  enum Base58Type {
73 
75  };
76 
77  const Consensus::Params& GetConsensus() const { return consensus; }
79  uint16_t GetDefaultPort() const { return nDefaultPort; }
80 
81  const CBlock& GenesisBlock() const { return genesis; }
85  bool RequireStandard() const { return fRequireStandard; }
87  bool IsTestChain() const { return m_is_test_chain; }
89  bool IsMockableChain() const { return m_is_mockable_chain; }
90  uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
92  uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
98  std::string NetworkIDString() const { return strNetworkID; }
100  const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
101  const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
102  const std::string& Bech32HRP() const { return bech32_hrp; }
103  const std::vector<uint8_t>& FixedSeeds() const { return vFixedSeeds; }
104  const CCheckpointData& Checkpoints() const { return checkpointData; }
105 
108  const MapAssumeutxo& Assumeutxo() const { return m_assumeutxo_data; }
109 
110  const ChainTxData& TxData() const { return chainTxData; }
111 protected:
113 
116  uint16_t nDefaultPort;
120  std::vector<std::string> vSeeds;
121  std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
122  std::string bech32_hrp;
123  std::string strNetworkID;
125  std::vector<uint8_t> vFixedSeeds;
133 };
134 
140 std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain);
141 
146 const CChainParams &Params();
147 
152 void SelectParams(const std::string& chain);
153 
154 #endif // BITCOIN_CHAINPARAMS_H
CChainParams::m_assumed_blockchain_size
uint64_t m_assumed_blockchain_size
Definition: chainparams.h:118
CreateChainParams
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
Definition: chainparams.cpp:543
block.h
CChainParams::IsMockableChain
bool IsMockableChain() const
If this chain allows time to be mocked.
Definition: chainparams.h:89
CChainParams::EXT_PUBLIC_KEY
@ EXT_PUBLIC_KEY
Definition: chainparams.h:71
CChainParams::strNetworkID
std::string strNetworkID
Definition: chainparams.h:123
CChainParams::chainTxData
ChainTxData chainTxData
Definition: chainparams.h:132
CChainParams::m_assumed_chain_state_size
uint64_t m_assumed_chain_state_size
Definition: chainparams.h:119
CChainParams::CChainParams
CChainParams()
Definition: chainparams.h:112
AssumeutxoData
Holds configuration for use during UTXO snapshot load and validation.
Definition: chainparams.h:33
CChainParams::IsTestChain
bool IsTestChain() const
If this chain is exclusively used for testing.
Definition: chainparams.h:87
CChainParams::fRequireStandard
bool fRequireStandard
Definition: chainparams.h:127
chainparamsbase.h
CChainParams::bech32_hrp
std::string bech32_hrp
Definition: chainparams.h:122
CChainParams
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:64
CChainParams::vSeeds
std::vector< std::string > vSeeds
Definition: chainparams.h:120
CChainParams::m_is_test_chain
bool m_is_test_chain
Definition: chainparams.h:128
CChainParams::GetConsensus
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:77
AssumeutxoData::hash_serialized
const uint256 hash_serialized
The expected hash of the deserialized UTXO set.
Definition: chainparams.h:35
CCheckpointData::mapCheckpoints
MapCheckpoints mapCheckpoints
Definition: chainparams.h:20
CChainParams::pchMessageStart
CMessageHeader::MessageStartChars pchMessageStart
Definition: chainparams.h:115
ChainTxData::nTime
int64_t nTime
UNIX timestamp of last known number of transactions.
Definition: chainparams.h:55
CChainParams::fDefaultConsistencyChecks
bool fDefaultConsistencyChecks
Definition: chainparams.h:126
CChainParams::MAX_BASE58_TYPES
@ MAX_BASE58_TYPES
Definition: chainparams.h:74
CChainParams::m_is_mockable_chain
bool m_is_mockable_chain
Definition: chainparams.h:129
CChainParams::PruneAfterHeight
uint64_t PruneAfterHeight() const
Definition: chainparams.h:90
CChainParams::FixedSeeds
const std::vector< uint8_t > & FixedSeeds() const
Definition: chainparams.h:103
CChainParams::genesis
CBlock genesis
Definition: chainparams.h:124
Consensus::Params
Parameters that influence chain consensus.
Definition: params.h:56
protocol.h
CChainParams::nDefaultPort
uint16_t nDefaultPort
Definition: chainparams.h:116
SelectParams
void SelectParams(const std::string &chain)
Sets the params returned by Params() to those for the given chain name.
Definition: chainparams.cpp:557
CChainParams::SECRET_KEY
@ SECRET_KEY
Definition: chainparams.h:70
CChainParams::AssumedBlockchainSize
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
Definition: chainparams.h:92
ChainTxData::nTxCount
int64_t nTxCount
total number of transactions between genesis and that timestamp
Definition: chainparams.h:56
ChainTxData
Holds various statistics on transactions within a chain.
Definition: chainparams.h:54
CChainParams::Base58Prefix
const std::vector< unsigned char > & Base58Prefix(Base58Type type) const
Definition: chainparams.h:101
CChainParams::NetworkIDString
std::string NetworkIDString() const
Return the network string.
Definition: chainparams.h:98
CCheckpointData
Definition: chainparams.h:19
MapCheckpoints
std::map< int, uint256 > MapCheckpoints
Definition: chainparams.h:17
CChainParams::GenesisBlock
const CBlock & GenesisBlock() const
Definition: chainparams.h:81
uint256
256-bit opaque blob.
Definition: uint256.h:124
CChainParams::checkpointData
CCheckpointData checkpointData
Definition: chainparams.h:130
CChainParams::Base58Type
Base58Type
Definition: chainparams.h:67
ChainTxData::dTxRate
double dTxRate
estimated number of transactions per second after that timestamp
Definition: chainparams.h:57
CChainParams::MessageStart
const CMessageHeader::MessageStartChars & MessageStart() const
Definition: chainparams.h:78
CChainParams::AssumedChainStateSize
uint64_t AssumedChainStateSize() const
Minimum free space (in GB) needed for data directory when pruned; Does not include prune target.
Definition: chainparams.h:94
CChainParams::DNSSeeds
const std::vector< std::string > & DNSSeeds() const
Return the list of hostnames to look up for DNS seeds.
Definition: chainparams.h:100
Consensus::Params::fPowNoRetargeting
bool fPowNoRetargeting
Definition: params.h:88
CCheckpointData::GetHeight
int GetHeight() const
Definition: chainparams.h:22
CChainParams::base58Prefixes
std::vector< unsigned char > base58Prefixes[MAX_BASE58_TYPES]
Definition: chainparams.h:121
CBlock
Definition: block.h:62
CChainParams::EXT_SECRET_KEY
@ EXT_SECRET_KEY
Definition: chainparams.h:72
operator<<
std::ostream & operator<<(std::ostream &o, const AssumeutxoData &aud)
Definition: chainparams.cpp:563
ArgsManager
Definition: system.h:166
CChainParams::Checkpoints
const CCheckpointData & Checkpoints() const
Definition: chainparams.h:104
CChainParams::RequireStandard
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
Definition: chainparams.h:85
params.h
CChainParams::TxData
const ChainTxData & TxData() const
Definition: chainparams.h:110
CMessageHeader::MessageStartChars
unsigned char MessageStartChars[MESSAGE_START_SIZE]
Definition: protocol.h:38
CChainParams::PUBKEY_ADDRESS
@ PUBKEY_ADDRESS
Definition: chainparams.h:68
CChainParams::vFixedSeeds
std::vector< uint8_t > vFixedSeeds
Definition: chainparams.h:125
CChainParams::MineBlocksOnDemand
bool MineBlocksOnDemand() const
Whether it is possible to mine blocks on demand (no retargeting)
Definition: chainparams.h:96
AssumeutxoData::nChainTx
const unsigned int nChainTx
Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex().
Definition: chainparams.h:41
CChainParams::consensus
Consensus::Params consensus
Definition: chainparams.h:114
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:538
CChainParams::Assumeutxo
const MapAssumeutxo & Assumeutxo() const
Get allowed assumeutxo configuration.
Definition: chainparams.h:108
CChainParams::Bech32HRP
const std::string & Bech32HRP() const
Definition: chainparams.h:102
CChainParams::nPruneAfterHeight
uint64_t nPruneAfterHeight
Definition: chainparams.h:117
CChainParams::SCRIPT_ADDRESS
@ SCRIPT_ADDRESS
Definition: chainparams.h:69
MapAssumeutxo
std::map< int, const AssumeutxoData > MapAssumeutxo
Definition: chainparams.h:46
CChainParams::m_assumeutxo_data
MapAssumeutxo m_assumeutxo_data
Definition: chainparams.h:131
CChainParams::DefaultConsistencyChecks
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
Definition: chainparams.h:83
CChainParams::GetDefaultPort
uint16_t GetDefaultPort() const
Definition: chainparams.h:79