Bitcoin ABC  0.24.10
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 
45 std::unique_ptr<CBaseChainParams>
46 CreateBaseChainParams(const std::string &chain) {
47  if (chain == CBaseChainParams::MAIN) {
48  return std::make_unique<CBaseChainParams>("", 8332, 8334);
49  }
50 
51  if (chain == CBaseChainParams::TESTNET) {
52  return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
53  }
54 
55  if (chain == CBaseChainParams::REGTEST) {
56  return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
57  }
58 
59  throw std::runtime_error(
60  strprintf("%s: Unknown chain %s.", __func__, chain));
61 }
62 
63 void SelectBaseParams(const std::string &chain) {
66 }
ArgsManager::ALLOW_ANY
@ ALLOW_ANY
Definition: system.h:155
chainparamsbase.h
SetupChainParamsBaseOptions
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
Definition: chainparamsbase.cpp:17
CBaseChainParams::TESTNET
static const std::string TESTNET
Definition: chainparamsbase.h:22
SelectBaseParams
void SelectBaseParams(const std::string &chain)
Sets the params returned by Params() to those for the given network.
Definition: chainparamsbase.cpp:63
CBaseChainParams
CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) of a given ins...
Definition: chainparamsbase.h:18
tinyformat.h
ArgsManager::DEBUG_ONLY
@ DEBUG_ONLY
Definition: system.h:156
ArgsManager::AddArg
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:649
CBaseChainParams::REGTEST
static const std::string REGTEST
Definition: chainparamsbase.h:23
CreateBaseChainParams
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have been chosen arbitrarily to...
Definition: chainparamsbase.cpp:46
CBaseChainParams::MAIN
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
Definition: chainparamsbase.h:21
ArgsManager::SelectConfigNetwork
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition: system.cpp:301
system.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1201
ArgsManager
Definition: system.h:148
BaseParams
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
Definition: chainparamsbase.cpp:36
gArgs
ArgsManager gArgs
Definition: system.cpp:76
globalChainBaseParams
static std::unique_ptr< CBaseChainParams > globalChainBaseParams
Definition: chainparamsbase.cpp:34
OptionsCategory::CHAINPARAMS
@ CHAINPARAMS