]>
Commit | Line | Data |
---|---|---|
f914f1a7 | 1 | // Copyright (c) 2014 The Bitcoin Core developers |
f2e03ffa | 2 | // Distributed under the MIT software license, see the accompanying |
84ce18ca WL |
3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | ||
84738627 PJ |
5 | #ifndef BITCOIN_CHAINPARAMSBASE_H |
6 | #define BITCOIN_CHAINPARAMSBASE_H | |
84ce18ca | 7 | |
84ce18ca | 8 | #include <string> |
611116d4 | 9 | #include <vector> |
84ce18ca WL |
10 | |
11 | /** | |
12 | * CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) | |
13 | * of a given instance of the Bitcoin system. | |
14 | */ | |
15 | class CBaseChainParams | |
16 | { | |
17 | public: | |
18 | enum Network { | |
19 | MAIN, | |
20 | TESTNET, | |
21 | REGTEST, | |
22 | ||
23 | MAX_NETWORK_TYPES | |
24 | }; | |
25 | ||
26 | const std::string& DataDir() const { return strDataDir; } | |
27 | int RPCPort() const { return nRPCPort; } | |
20e01b1a | 28 | |
84ce18ca WL |
29 | protected: |
30 | CBaseChainParams() {} | |
31 | ||
9a4127e7 | 32 | int nRPCPort = 0; |
84ce18ca | 33 | std::string strDataDir; |
84ce18ca WL |
34 | }; |
35 | ||
36 | /** | |
7e6d23b1 CD |
37 | * Return the currently selected parameters. This won't change after app |
38 | * startup, except for unit tests. | |
84ce18ca | 39 | */ |
20e01b1a | 40 | const CBaseChainParams& BaseParams(); |
84ce18ca WL |
41 | |
42 | /** Sets the params returned by Params() to those for the given network. */ | |
43 | void SelectBaseParams(CBaseChainParams::Network network); | |
44 | ||
45 | /** | |
b796cb08 | 46 | * Looks for -regtest or -testnet and returns the appropriate Network ID. |
47 | * Returns MAX_NETWORK_TYPES if an invalid combination is given. | |
48 | */ | |
49 | CBaseChainParams::Network NetworkIdFromCommandLine(); | |
50 | ||
51 | /** | |
52 | * Calls NetworkIdFromCommandLine() and then calls SelectParams as appropriate. | |
84ce18ca WL |
53 | * Returns false if an invalid combination is given. |
54 | */ | |
55 | bool SelectBaseParamsFromCommandLine(); | |
56 | ||
96ff9d64 WL |
57 | /** |
58 | * Return true if SelectBaseParamsFromCommandLine() has been called to select | |
59 | * a network. | |
60 | */ | |
61 | bool AreBaseParamsConfigured(); | |
62 | ||
84738627 | 63 | #endif // BITCOIN_CHAINPARAMSBASE_H |