Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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 <common/args.h>
9#include <tinyformat.h>
10
11#include <cassert>
12
13const std::string CBaseChainParams::MAIN = "main";
14const std::string CBaseChainParams::TESTNET = "test";
15const 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
34static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
35
40
45std::unique_ptr<CBaseChainParams>
46CreateBaseChainParams(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
68void SelectBaseParams(const std::string &chain) {
71}
ArgsManager gArgs
Definition args.cpp:38
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have been chosen arbitrarily to...
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.
@ ALLOW_ANY
Definition args.h:103
@ DEBUG_ONLY
Definition args.h:104
void SelectConfigNetwork(const std::string &network)
Select the network in use.
Definition args.cpp:172
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)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
assert(!tx.IsCoinBase())