Bitcoin ABC  0.24.10
P2P Digital Currency
chainparams.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 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 struct SeedSpec6 {
18  uint8_t addr[16];
19  uint16_t port;
20 };
21 
22 typedef std::map<int, BlockHash> MapCheckpoints;
23 
26 };
27 
34 struct ChainTxData {
35  int64_t nTime;
36  int64_t nTxCount;
37  double dTxRate;
38 };
39 
47 class CChainParams {
48 public:
49  enum Base58Type {
55 
57  };
58 
59  const Consensus::Params &GetConsensus() const { return consensus; }
61  const CMessageHeader::MessageMagic &NetMagic() const { return netMagic; }
62  int GetDefaultPort() const { return nDefaultPort; }
63 
64  const CBlock &GenesisBlock() const { return genesis; }
68  bool RequireStandard() const { return fRequireStandard; }
70  bool IsTestChain() const { return m_is_test_chain; }
72  bool IsMockableChain() const { return m_is_mockable_chain; }
73  uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
75  uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
80  uint64_t AssumedChainStateSize() const {
82  }
86  std::string NetworkIDString() const { return strNetworkID; }
88  const std::vector<uint8_t> &Base58Prefix(Base58Type type) const {
89  return base58Prefixes[type];
90  }
91  const std::string &CashAddrPrefix() const { return cashaddrPrefix; }
92  const std::vector<SeedSpec6> &FixedSeeds() const { return vFixedSeeds; }
93  const CCheckpointData &Checkpoints() const { return checkpointData; }
94  const ChainTxData &TxData() const { return chainTxData; }
95 
96 protected:
98 
106  std::vector<std::string> vSeeds;
107  std::vector<uint8_t> base58Prefixes[MAX_BASE58_TYPES];
108  std::string cashaddrPrefix;
109  std::string strNetworkID;
111  std::vector<SeedSpec6> vFixedSeeds;
118 
119  friend const std::vector<std::string>
120  GetRandomizedDNSSeeds(const CChainParams &params);
121 };
122 
128 std::unique_ptr<CChainParams> CreateChainParams(const std::string &chain);
129 
130 CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits,
131  int32_t nVersion, const Amount genesisReward);
132 
137 const CChainParams &Params();
138 
143 void SelectParams(const std::string &chain);
144 
145 const CCheckpointData &CheckpointData(const std::string &chain);
146 
147 #endif // BITCOIN_CHAINPARAMS_H
CChainParams::m_assumed_blockchain_size
uint64_t m_assumed_blockchain_size
Definition: chainparams.h:104
block.h
CChainParams::cashaddrPrefix
std::string cashaddrPrefix
Definition: chainparams.h:108
CChainParams::IsMockableChain
bool IsMockableChain() const
If this chain allows time to be mocked.
Definition: chainparams.h:72
CChainParams::EXT_PUBLIC_KEY
@ EXT_PUBLIC_KEY
Definition: chainparams.h:53
CChainParams::strNetworkID
std::string strNetworkID
Definition: chainparams.h:109
CChainParams::chainTxData
ChainTxData chainTxData
Definition: chainparams.h:117
CChainParams::m_assumed_chain_state_size
uint64_t m_assumed_chain_state_size
Definition: chainparams.h:105
CChainParams::CChainParams
CChainParams()
Definition: chainparams.h:97
CChainParams::IsTestChain
bool IsTestChain() const
If this chain is exclusively used for testing.
Definition: chainparams.h:70
CChainParams::fRequireStandard
bool fRequireStandard
Definition: chainparams.h:113
chainparamsbase.h
CChainParams
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:47
CChainParams::vSeeds
std::vector< std::string > vSeeds
Definition: chainparams.h:106
CChainParams::m_is_test_chain
bool m_is_test_chain
Definition: chainparams.h:114
CChainParams::netMagic
CMessageHeader::MessageMagic netMagic
Definition: chainparams.h:101
CChainParams::GetConsensus
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:59
CChainParams::vFixedSeeds
std::vector< SeedSpec6 > vFixedSeeds
Definition: chainparams.h:111
CCheckpointData::mapCheckpoints
MapCheckpoints mapCheckpoints
Definition: chainparams.h:25
CChainParams::FixedSeeds
const std::vector< SeedSpec6 > & FixedSeeds() const
Definition: chainparams.h:92
MapCheckpoints
std::map< int, BlockHash > MapCheckpoints
Definition: chainparams.h:22
ChainTxData::nTime
int64_t nTime
Definition: chainparams.h:35
CChainParams::fDefaultConsistencyChecks
bool fDefaultConsistencyChecks
Definition: chainparams.h:112
CChainParams::MAX_BASE58_TYPES
@ MAX_BASE58_TYPES
Definition: chainparams.h:56
CChainParams::m_is_mockable_chain
bool m_is_mockable_chain
Definition: chainparams.h:115
CChainParams::PruneAfterHeight
uint64_t PruneAfterHeight() const
Definition: chainparams.h:73
CChainParams::base58Prefixes
std::vector< uint8_t > base58Prefixes[MAX_BASE58_TYPES]
Definition: chainparams.h:107
CChainParams::genesis
CBlock genesis
Definition: chainparams.h:110
Consensus::Params
Parameters that influence chain consensus.
Definition: params.h:59
protocol.h
SelectParams
void SelectParams(const std::string &chain)
Sets the params returned by Params() to those for the given BIP70 chain name.
Definition: chainparams.cpp:530
CChainParams::SECRET_KEY
@ SECRET_KEY
Definition: chainparams.h:52
CChainParams::CashAddrPrefix
const std::string & CashAddrPrefix() const
Definition: chainparams.h:91
CChainParams::AssumedBlockchainSize
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
Definition: chainparams.h:75
ChainTxData::nTxCount
int64_t nTxCount
Definition: chainparams.h:36
ChainTxData
Holds various statistics on transactions within a chain.
Definition: chainparams.h:34
CChainParams::GetRandomizedDNSSeeds
const friend std::vector< std::string > GetRandomizedDNSSeeds(const CChainParams &params)
Return the list of hostnames to look up for DNS seeds.
Definition: dnsseeds.cpp:11
CChainParams::NetworkIDString
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
Definition: chainparams.h:86
CCheckpointData
Definition: chainparams.h:24
CChainParams::GenesisBlock
const CBlock & GenesisBlock() const
Definition: chainparams.h:64
CheckpointData
const CCheckpointData & CheckpointData(const std::string &chain)
Definition: checkpoints.cpp:113
CChainParams::nDefaultPort
int nDefaultPort
Definition: chainparams.h:102
Amount
Definition: amount.h:19
CChainParams::checkpointData
CCheckpointData checkpointData
Definition: chainparams.h:116
CChainParams::Base58Type
Base58Type
Definition: chainparams.h:49
ChainTxData::dTxRate
double dTxRate
Definition: chainparams.h:37
CChainParams::GetDefaultPort
int GetDefaultPort() const
Definition: chainparams.h:62
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:80
CreateChainParams
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
Definition: chainparams.cpp:513
Consensus::Params::fPowNoRetargeting
bool fPowNoRetargeting
Definition: params.h:106
CBlock
Definition: block.h:55
CChainParams::DiskMagic
const CMessageHeader::MessageMagic & DiskMagic() const
Definition: chainparams.h:60
CChainParams::EXT_SECRET_KEY
@ EXT_SECRET_KEY
Definition: chainparams.h:54
SeedSpec6::port
uint16_t port
Definition: chainparams.h:19
CChainParams::Checkpoints
const CCheckpointData & Checkpoints() const
Definition: chainparams.h:93
CChainParams::RequireStandard
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
Definition: chainparams.h:68
params.h
CChainParams::TxData
const ChainTxData & TxData() const
Definition: chainparams.h:94
CMessageHeader::MessageMagic
std::array< uint8_t, MESSAGE_START_SIZE > MessageMagic
Definition: protocol.h:49
SeedSpec6::addr
uint8_t addr[16]
Definition: chainparams.h:18
CChainParams::PUBKEY_ADDRESS
@ PUBKEY_ADDRESS
Definition: chainparams.h:50
CChainParams::MineBlocksOnDemand
bool MineBlocksOnDemand() const
Whether it is possible to mine blocks on demand (no retargeting)
Definition: chainparams.h:84
CChainParams::consensus
Consensus::Params consensus
Definition: chainparams.h:99
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:508
CreateGenesisBlock
CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const Amount genesisReward)
Build the genesis block.
Definition: chainparams.cpp:61
CChainParams::diskMagic
CMessageHeader::MessageMagic diskMagic
Definition: chainparams.h:100
CChainParams::NetMagic
const CMessageHeader::MessageMagic & NetMagic() const
Definition: chainparams.h:61
SeedSpec6
Definition: chainparams.h:17
CChainParams::nPruneAfterHeight
uint64_t nPruneAfterHeight
Definition: chainparams.h:103
CChainParams::Base58Prefix
const std::vector< uint8_t > & Base58Prefix(Base58Type type) const
Return the list of hostnames to look up for DNS seeds.
Definition: chainparams.h:88
CChainParams::SCRIPT_ADDRESS
@ SCRIPT_ADDRESS
Definition: chainparams.h:51
CChainParams::DefaultConsistencyChecks
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
Definition: chainparams.h:66