1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2013 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #ifndef BITCOIN_CHAIN_PARAMS_H
7 #define BITCOIN_CHAIN_PARAMS_H
17 #define MESSAGE_START_SIZE 4
18 typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
25 CDNSSeedData(const string &strName, const 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.
56 const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
57 const MessageStartChars& MessageStart() const { return pchMessageStart; }
58 const vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
59 int GetDefaultPort() const { return nDefaultPort; }
60 const CBigNum& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
61 int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
62 virtual const CBlock& GenesisBlock() const = 0;
63 virtual bool RequireRPCPassword() const { return true; }
64 const string& DataDir() const { return strDataDir; }
65 virtual Network NetworkID() const = 0;
66 const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
67 const std::vector<unsigned char> &Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
68 virtual const vector<CAddress>& FixedSeeds() const = 0;
69 int RPCPort() const { return nRPCPort; }
73 uint256 hashGenesisBlock;
74 MessageStartChars pchMessageStart;
75 // Raw pub key bytes for the broadcast alert signing key.
76 vector<unsigned char> vAlertPubKey;
79 CBigNum bnProofOfWorkLimit;
80 int nSubsidyHalvingInterval;
82 vector<CDNSSeedData> vSeeds;
83 std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
87 * Return the currently selected parameters. This won't change after app startup
88 * outside of the unit tests.
90 const CChainParams &Params();
92 /** Sets the params returned by Params() to those for the given network. */
93 void SelectParams(CChainParams::Network network);
96 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
97 * Returns false if an invalid combination is given.
99 bool SelectParamsFromCommandLine();
101 inline bool TestNet() {
102 // Note: it's deliberate that this returns "false" for regression test mode.
103 return Params().NetworkID() == CChainParams::TESTNET;
106 inline bool RegTest() {
107 return Params().NetworkID() == CChainParams::REGTEST;