1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 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"
17 std::string name, host;
18 CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
26 typedef std::map<int, uint256> MapCheckpoints;
28 struct CCheckpointData {
29 MapCheckpoints mapCheckpoints;
30 int64_t nTimeLastCheckpoint;
31 int64_t nTransactionsLastCheckpoint;
32 double fTransactionsPerDay;
36 * CChainParams defines various tweakable parameters of a given instance of the
37 * Bitcoin system. There are three: the main network on which people trade goods
38 * and services, the public test network which gets reset from time to time and
39 * a regression test mode which is intended for private networks only. It has
40 * minimal difficulty to ensure that blocks can be found instantly.
60 SAPLING_PAYMENT_ADDRESS,
61 SAPLING_FULL_VIEWING_KEY,
62 SAPLING_INCOMING_VIEWING_KEY,
68 const Consensus::Params& GetConsensus() const { return consensus; }
69 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
70 const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
71 int GetDefaultPort() const { return nDefaultPort; }
73 const CBlock& GenesisBlock() const { return genesis; }
74 /** Make miner wait to have peers to avoid wasting work */
75 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
76 /** Default value for -checkmempool and -checkblockindex argument */
77 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
78 /** Policy: Filter transactions that do not match well-defined patterns */
79 bool RequireStandard() const { return fRequireStandard; }
80 int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
81 unsigned int EquihashN() const { return nEquihashN; }
82 unsigned int EquihashK() const { return nEquihashK; }
83 std::string CurrencyUnits() const { return strCurrencyUnits; }
84 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
85 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
86 /** In the future use NetworkIDString() for RPC fields */
87 bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
88 /** Return the BIP70 network string (main, test or regtest) */
89 std::string NetworkIDString() const { return strNetworkID; }
90 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
91 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
92 const std::string& Bech32HRP(Bech32Type type) const { return bech32HRPs[type]; }
93 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
94 const CCheckpointData& Checkpoints() const { return checkpointData; }
95 /** Return the founder's reward address and script for a given block height */
96 std::string GetFoundersRewardAddressAtHeight(int height) const;
97 CScript GetFoundersRewardScriptAtHeight(int height) const;
98 std::string GetFoundersRewardAddressAtIndex(int i) const;
99 /** Enforce coinbase consensus rule in regtest mode */
100 void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
104 Consensus::Params consensus;
105 CMessageHeader::MessageStartChars pchMessageStart;
106 //! Raw pub key bytes for the broadcast alert signing key.
107 std::vector<unsigned char> vAlertPubKey;
108 int nDefaultPort = 0;
109 uint64_t nPruneAfterHeight = 0;
110 unsigned int nEquihashN = 0;
111 unsigned int nEquihashK = 0;
112 std::vector<CDNSSeedData> vSeeds;
113 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
114 std::string bech32HRPs[MAX_BECH32_TYPES];
115 std::string strNetworkID;
116 std::string strCurrencyUnits;
118 std::vector<SeedSpec6> vFixedSeeds;
119 bool fMiningRequiresPeers = false;
120 bool fDefaultConsistencyChecks = false;
121 bool fRequireStandard = false;
122 bool fMineBlocksOnDemand = false;
123 bool fTestnetToBeDeprecatedFieldRPC = false;
124 CCheckpointData checkpointData;
125 std::vector<std::string> vFoundersRewardAddress;
129 * Return the currently selected parameters. This won't change after app
130 * startup, except for unit tests.
132 const CChainParams &Params();
134 /** Return parameters for the given network. */
135 CChainParams &Params(CBaseChainParams::Network network);
137 /** Sets the params returned by Params() to those for the given network. */
138 void SelectParams(CBaseChainParams::Network network);
141 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
142 * Returns false if an invalid combination is given.
144 bool SelectParamsFromCommandLine();
147 * Allows modifying the network upgrade regtest parameters.
149 void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight);
151 #endif // BITCOIN_CHAINPARAMS_H