Bitcoin Core  0.20.99
P2P Digital Currency
chainparamsbase.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2019 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 #include <util/memory.h>
11 
12 #include <assert.h>
13 
14 const std::string CBaseChainParams::MAIN = "main";
15 const std::string CBaseChainParams::TESTNET = "test";
16 const std::string CBaseChainParams::SIGNET = "signet";
17 const std::string CBaseChainParams::REGTEST = "regtest";
18 
20 {
21  argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
22  argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
23  "This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
24  argsman.AddArg("-segwitheight=<n>", "Set the activation height of segwit. -1 to disable. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
25  argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
26  argsman.AddArg("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
27  argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
28  argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_STRING, OptionsCategory::CHAINPARAMS);
29  argsman.AddArg("-signetseednode", "Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s))", ArgsManager::ALLOW_STRING, OptionsCategory::CHAINPARAMS);
30 }
31 
32 static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
33 
35 {
36  assert(globalChainBaseParams);
37  return *globalChainBaseParams;
38 }
39 
44 std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
45 {
46  if (chain == CBaseChainParams::MAIN) {
47  return MakeUnique<CBaseChainParams>("", 8332, 8334);
48  } else if (chain == CBaseChainParams::TESTNET) {
49  return MakeUnique<CBaseChainParams>("testnet3", 18332, 18334);
50  } else if (chain == CBaseChainParams::SIGNET) {
51  return MakeUnique<CBaseChainParams>("signet", 38332, 38334);
52  } else if (chain == CBaseChainParams::REGTEST) {
53  return MakeUnique<CBaseChainParams>("regtest", 18443, 18445);
54  }
55  throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
56 }
57 
58 void SelectBaseParams(const std::string& chain)
59 {
62 }
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have been chosen arbitrarily to...
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:1164
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition: system.cpp:277
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
static const std::string MAIN
Chain name strings.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: system.cpp:506
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.
static const std::string SIGNET