Bitcoin ABC  0.22.13
P2P Digital Currency
chainparamsbase.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 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.
5 
6 #include <chainparamsbase.h>
7 
8 #include <tinyformat.h>
9 #include <util/system.h>
10 
11 #include <cassert>
12 
13 const std::string CBaseChainParams::MAIN = "main";
14 const std::string CBaseChainParams::TESTNET = "test";
15 const std::string CBaseChainParams::REGTEST = "regtest";
16 
18  argsman.AddArg(
19  "-chain=<chain>",
20  "Use the chain <chain> (default: main). Allowed values: main, "
21  "test, regtest",
23  argsman.AddArg(
24  "-regtest",
25  "Enter regression test mode, which uses a special chain in which "
26  "blocks can be solved instantly. This is intended for regression "
27  "testing tools and app development. Equivalent to -chain=regtest.",
30  argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.",
32 }
33 
34 static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
35 
37  assert(globalChainBaseParams);
38  return *globalChainBaseParams;
39 }
40 
41 std::unique_ptr<CBaseChainParams>
42 CreateBaseChainParams(const std::string &chain) {
43  if (chain == CBaseChainParams::MAIN) {
44  return std::make_unique<CBaseChainParams>("", 8332);
45  }
46 
47  if (chain == CBaseChainParams::TESTNET) {
48  return std::make_unique<CBaseChainParams>("testnet3", 18332);
49  }
50 
51  if (chain == CBaseChainParams::REGTEST) {
52  return std::make_unique<CBaseChainParams>("regtest", 18443);
53  }
54 
55  throw std::runtime_error(
56  strprintf("%s: Unknown chain %s.", __func__, chain));
57 }
58 
59 void SelectBaseParams(const std::string &chain) {
62 }
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CBaseChainParams> of the chosen chain.
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
static const std::string REGTEST
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1201
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition: system.cpp:289
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:546
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
ArgsManager gArgs
Definition: system.cpp:76
static std::unique_ptr< CBaseChainParams > globalChainBaseParams
static const std::string TESTNET
void SelectBaseParams(const std::string &chain)
Sets the params returned by Params() to those for the given network.