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.
48 const Consensus::Params& GetConsensus() const { return consensus; }
49 const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
50 const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
51 int GetDefaultPort() const { return nDefaultPort; }
53 /** Used if GenerateBitcoins is called with a negative number of threads */
54 int DefaultMinerThreads() const { return nMinerThreads; }
55 const CBlock& GenesisBlock() const { return genesis; }
56 bool RequireRPCPassword() const { return fRequireRPCPassword; }
57 /** Make miner wait to have peers to avoid wasting work */
58 bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
59 /** Default value for -checkmempool and -checkblockindex argument */
60 bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
61 /** Policy: Filter transactions that do not match well-defined patterns */
62 bool RequireStandard() const { return fRequireStandard; }
63 int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
64 /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
65 bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
66 /** In the future use NetworkIDString() for RPC fields */
67 bool TestnetToBeDeprecatedFieldRPC() const { return fTestnetToBeDeprecatedFieldRPC; }
68 /** Return the BIP70 network string (main, test or regtest) */
69 std::string NetworkIDString() const { return strNetworkID; }
70 const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
71 const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
72 const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
73 const Checkpoints::CCheckpointData& Checkpoints() const { return checkpointData; }
77 Consensus::Params consensus;
78 CMessageHeader::MessageStartChars pchMessageStart;
79 //! Raw pub key bytes for the broadcast alert signing key.
80 std::vector<unsigned char> vAlertPubKey;
83 uint64_t nPruneAfterHeight;
84 std::vector<CDNSSeedData> vSeeds;
85 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
86 std::string strNetworkID;
88 std::vector<SeedSpec6> vFixedSeeds;
89 bool fRequireRPCPassword;
90 bool fMiningRequiresPeers;
91 bool fDefaultConsistencyChecks;
92 bool fRequireStandard;
93 bool fMineBlocksOnDemand;
94 bool fTestnetToBeDeprecatedFieldRPC;
95 Checkpoints::CCheckpointData checkpointData;
99 * Return the currently selected parameters. This won't change after app
100 * startup, except for unit tests.
102 const CChainParams &Params();
104 /** Return parameters for the given network. */
105 CChainParams &Params(CBaseChainParams::Network network);
107 /** Sets the params returned by Params() to those for the given network. */
108 void SelectParams(CBaseChainParams::Network network);
111 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
112 * Returns false if an invalid combination is given.
114 bool SelectParamsFromCommandLine();
116 #endif // BITCOIN_CHAINPARAMS_H