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) {}
23 * CChainParams defines various tweakable parameters of a given instance of the
24 * Bitcoin system. There are three: the main network on which people trade goods
25 * and services, the public test network which gets reset from time to time and
26 * a regression test mode which is intended for private networks only. It has
27 * minimal difficulty to ensure that blocks can be found instantly.
42 const Consensus::Params& GetConsensus() const { return consensus; }
43 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
44 const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
45 int GetDefaultPort() const { return nDefaultPort; }
46 int SubsidyHalvingInterval() const { return consensus.nSubsidyHalvingInterval; }
47 int EnforceBlockUpgradeMajority() const { return consensus.nMajorityEnforceBlockUpgrade; }
48 int RejectBlockOutdatedMajority() const { return consensus.nMajorityRejectBlockOutdated; }
49 int ToCheckBlockUpgradeMajority() const { return consensus.nMajorityWindow; }
51 /** Used if GenerateBitcoins is called with a negative number of threads */
52 int DefaultMinerThreads() const { return nMinerThreads; }
53 const CBlock& GenesisBlock() const { return genesis; }
54 bool RequireRPCPassword() const { return fRequireRPCPassword; }
55 /** Make miner wait to have peers to avoid wasting work */
56 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
57 /** Default value for -checkmempool and -checkblockindex argument */
58 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
59 /** Make standard checks */
60 bool RequireStandard() const { return fRequireStandard; }
61 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
62 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
63 /** In the future use NetworkIDString() for RPC fields */
64 bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
65 /** Return the BIP70 network string (main, test or regtest) */
66 std::string NetworkIDString() const { return strNetworkID; }
67 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
68 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
69 const std::vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
70 virtual const Checkpoints::CCheckpointData& Checkpoints() const = 0;
74 Consensus::Params consensus;
75 CMessageHeader::MessageStartChars pchMessageStart;
76 //! Raw pub key bytes for the broadcast alert signing key.
77 std::vector<unsigned char> vAlertPubKey;
80 std::vector<CDNSSeedData> vSeeds;
81 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
82 std::string strNetworkID;
84 std::vector<CAddress> vFixedSeeds;
85 bool fRequireRPCPassword;
86 bool fMiningRequiresPeers;
87 bool fDefaultConsistencyChecks;
88 bool fRequireStandard;
89 bool fMineBlocksOnDemand;
90 bool fTestnetToBeDeprecatedFieldRPC;
94 * Return the currently selected parameters. This won't change after app startup
95 * outside of the unit tests.
97 const CChainParams &Params();
99 /** Return parameters for the given network. */
100 CChainParams &Params(CBaseChainParams::Network network);
102 /** Sets the params returned by Params() to those for the given network. */
103 void SelectParams(CBaseChainParams::Network network);
106 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
107 * Returns false if an invalid combination is given.
109 bool SelectParamsFromCommandLine();
111 #endif // BITCOIN_CHAINPARAMS_H