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 "checkpoints.h"
11 #include "consensus/params.h"
12 #include "primitives/block.h"
18 std::string name, host;
19 CDNSSeedData(const std::string &strName, const std::string &strHost) : name(strName), host(strHost) {}
29 * CChainParams defines various tweakable parameters of a given instance of the
30 * Bitcoin system. There are three: the main network on which people trade goods
31 * and services, the public test network which gets reset from time to time and
32 * a regression test mode which is intended for private networks only. It has
33 * minimal difficulty to ensure that blocks can be found instantly.
51 const Consensus::Params& GetConsensus() const { return consensus; }
52 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
53 const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
54 int GetDefaultPort() const { return nDefaultPort; }
56 /** Used if GenerateBitcoins is called with a negative number of threads */
57 int DefaultMinerThreads() const { return nMinerThreads; }
58 const CBlock& GenesisBlock() const { return genesis; }
59 bool RequireRPCPassword() const { return fRequireRPCPassword; }
60 /** Make miner wait to have peers to avoid wasting work */
61 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
62 /** Default value for -checkmempool and -checkblockindex argument */
63 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
64 /** Policy: Filter transactions that do not match well-defined patterns */
65 bool RequireStandard() const { return fRequireStandard; }
66 int64_t MaxTipAge() const { return nMaxTipAge; }
67 int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
68 unsigned int EquihashN() const { return nEquihashN; }
69 unsigned int EquihashK() const { return nEquihashK; }
70 std::string CurrencyUnits() const { return strCurrencyUnits; }
71 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
72 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
73 /** In the future use NetworkIDString() for RPC fields */
74 bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
75 /** Return the BIP70 network string (main, test or regtest) */
76 std::string NetworkIDString() const { return strNetworkID; }
77 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
78 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
79 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
80 const Checkpoints::CCheckpointData& Checkpoints() const { return checkpointData; }
81 /** Return the founder's reward address and script for a given block height */
82 std::string GetFoundersRewardAddressAtHeight(int height) const;
83 CScript GetFoundersRewardScriptAtHeight(int height) const;
84 std::string GetFoundersRewardAddressAtIndex(int i) const;
85 /** Enforce coinbase consensus rule in regtest mode */
86 void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; }
90 Consensus::Params consensus;
91 CMessageHeader::MessageStartChars pchMessageStart;
92 //! Raw pub key bytes for the broadcast alert signing key.
93 std::vector<unsigned char> vAlertPubKey;
95 int nMinerThreads = 0;
97 uint64_t nPruneAfterHeight = 0;
98 unsigned int nEquihashN = 0;
99 unsigned int nEquihashK = 0;
100 std::vector<CDNSSeedData> vSeeds;
101 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
102 std::string strNetworkID;
103 std::string strCurrencyUnits;
105 std::vector<SeedSpec6> vFixedSeeds;
106 bool fRequireRPCPassword = false;
107 bool fMiningRequiresPeers = false;
108 bool fDefaultConsistencyChecks = false;
109 bool fRequireStandard = false;
110 bool fMineBlocksOnDemand = false;
111 bool fTestnetToBeDeprecatedFieldRPC = false;
112 Checkpoints::CCheckpointData checkpointData;
113 std::vector<std::string> vFoundersRewardAddress;
117 * Return the currently selected parameters. This won't change after app
118 * startup, except for unit tests.
120 const CChainParams &Params();
122 /** Return parameters for the given network. */
123 CChainParams &Params(CBaseChainParams::Network network);
125 /** Sets the params returned by Params() to those for the given network. */
126 void SelectParams(CBaseChainParams::Network network);
129 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
130 * Returns false if an invalid combination is given.
132 bool SelectParamsFromCommandLine();
134 #endif // BITCOIN_CHAINPARAMS_H