Merge #12075: [scripts] Add missing univalue file to copyright_header.py
[bitcoinplatinum.git] / src / chainparams.h
blobecfe1a0ac3d5776c2889d934a2946f2732e456ae
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 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.
6 #ifndef BITCOIN_CHAINPARAMS_H
7 #define BITCOIN_CHAINPARAMS_H
9 #include <chainparamsbase.h>
10 #include <consensus/params.h>
11 #include <primitives/block.h>
12 #include <protocol.h>
14 #include <memory>
15 #include <vector>
17 struct CDNSSeedData {
18 std::string host;
19 bool supportsServiceBitsFiltering;
20 CDNSSeedData(const std::string &strHost, bool supportsServiceBitsFilteringIn) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
23 struct SeedSpec6 {
24 uint8_t addr[16];
25 uint16_t port;
28 typedef std::map<int, uint256> MapCheckpoints;
30 struct CCheckpointData {
31 MapCheckpoints mapCheckpoints;
34 struct ChainTxData {
35 int64_t nTime;
36 int64_t nTxCount;
37 double dTxRate;
40 /**
41 * CChainParams defines various tweakable parameters of a given instance of the
42 * Bitcoin system. There are three: the main network on which people trade goods
43 * and services, the public test network which gets reset from time to time and
44 * a regression test mode which is intended for private networks only. It has
45 * minimal difficulty to ensure that blocks can be found instantly.
47 class CChainParams
49 public:
50 enum Base58Type {
51 PUBKEY_ADDRESS,
52 SCRIPT_ADDRESS,
53 SECRET_KEY,
54 EXT_PUBLIC_KEY,
55 EXT_SECRET_KEY,
57 MAX_BASE58_TYPES
60 const Consensus::Params& GetConsensus() const { return consensus; }
61 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
62 int GetDefaultPort() const { return nDefaultPort; }
64 const CBlock& GenesisBlock() const { return genesis; }
65 /** Default value for -checkmempool and -checkblockindex argument */
66 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
67 /** Policy: Filter transactions that do not match well-defined patterns */
68 bool RequireStandard() const { return fRequireStandard; }
69 uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
70 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
71 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
72 /** Return the BIP70 network string (main, test or regtest) */
73 std::string NetworkIDString() const { return strNetworkID; }
74 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
75 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
76 const std::string& Bech32HRP() const { return bech32_hrp; }
77 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
78 const CCheckpointData& Checkpoints() const { return checkpointData; }
79 const ChainTxData& TxData() const { return chainTxData; }
80 void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
81 protected:
82 CChainParams() {}
84 Consensus::Params consensus;
85 CMessageHeader::MessageStartChars pchMessageStart;
86 int nDefaultPort;
87 uint64_t nPruneAfterHeight;
88 std::vector<CDNSSeedData> vSeeds;
89 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
90 std::string bech32_hrp;
91 std::string strNetworkID;
92 CBlock genesis;
93 std::vector<SeedSpec6> vFixedSeeds;
94 bool fDefaultConsistencyChecks;
95 bool fRequireStandard;
96 bool fMineBlocksOnDemand;
97 CCheckpointData checkpointData;
98 ChainTxData chainTxData;
102 * Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
103 * @returns a CChainParams* of the chosen chain.
104 * @throws a std::runtime_error if the chain is not supported.
106 std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain);
109 * Return the currently selected parameters. This won't change after app
110 * startup, except for unit tests.
112 const CChainParams &Params();
115 * Sets the params returned by Params() to those for the given BIP70 chain name.
116 * @throws std::runtime_error when the chain is not supported.
118 void SelectParams(const std::string& chain);
121 * Allows modifying the Version Bits regtest parameters.
123 void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
125 #endif // BITCOIN_CHAINPARAMS_H