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.
52 const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
53 const MessageStartChars& MessageStart() const { return pchMessageStart; }
54 const vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
55 int GetDefaultPort() const { return nDefaultPort; }
56 const CBigNum& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
57 int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
58 virtual const CBlock& GenesisBlock() const = 0;
59 virtual bool RequireRPCPassword() const { return true; }
60 const string& DataDir() const { return strDataDir; }
61 virtual Network NetworkID() const = 0;
62 const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
63 int Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
64 virtual const vector<CAddress>& FixedSeeds() const = 0;
65 int RPCPort() const { return nRPCPort; }
69 uint256 hashGenesisBlock;
70 MessageStartChars pchMessageStart;
71 // Raw pub key bytes for the broadcast alert signing key.
72 vector<unsigned char> vAlertPubKey;
75 CBigNum bnProofOfWorkLimit;
76 int nSubsidyHalvingInterval;
78 vector<CDNSSeedData> vSeeds;
79 int base58Prefixes[MAX_BASE58_TYPES];
83 * Return the currently selected parameters. This won't change after app startup
84 * outside of the unit tests.
86 const CChainParams &Params();
88 /** Sets the params returned by Params() to those for the given network. */
89 void SelectParams(CChainParams::Network network);
92 * Looks for -regtest or -testnet and then calls SelectParams as appropriate.
93 * Returns false if an invalid combination is given.
95 bool SelectParamsFromCommandLine();
97 inline bool TestNet() {
98 // Note: it's deliberate that this returns "false" for regression test mode.
99 return Params().NetworkID() == CChainParams::TESTNET;