Bitcoin ABC  0.28.12
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 
38  return *globalChainBaseParams;
39 }
40 
45 std::unique_ptr<CBaseChainParams>
46 CreateBaseChainParams(const std::string &chain) {
47  if (chain == CBaseChainParams::MAIN) {
48  return std::make_unique<CBaseChainParams>("", /*rpc_port=*/8332, 8334,
49  /*chronik_port=*/8331);
50  }
51 
52  if (chain == CBaseChainParams::TESTNET) {
53  return std::make_unique<CBaseChainParams>("testnet3",
54  /*rpc_port=*/18332, 18334,
55  /*chronik_port=*/18331);
56  }
57 
58  if (chain == CBaseChainParams::REGTEST) {
59  return std::make_unique<CBaseChainParams>("regtest", /*rpc_port=*/18443,
60  18445,
61  /*chronik_port=*/18442);
62  }
63 
64  throw std::runtime_error(
65  strprintf("%s: Unknown chain %s.", __func__, chain));
66 }
67 
68 void SelectBaseParams(const std::string &chain) {
71 }
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
static std::unique_ptr< CBaseChainParams > globalChainBaseParams
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
void SelectBaseParams(const std::string &chain)
Sets the params returned by Params() to those for the given network.
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have been chosen arbitrarily to...
@ ALLOW_ANY
Definition: system.h:161
@ DEBUG_ONLY
Definition: system.h:162
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition: system.cpp:293
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:729
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
static const std::string REGTEST
static const std::string TESTNET
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
ArgsManager gArgs
Definition: system.cpp:80
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1202
assert(!tx.IsCoinBase())