Bitcoin ABC 0.30.7
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 <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
39}
40
45std::unique_ptr<CBaseChainParams>
46CreateBaseChainParams(const std::string &chain) {
47 if (chain == CBaseChainParams::MAIN) {
48 return std::make_unique<CBaseChainParams>(
49 "", /*rpc_port=*/8332, 8334,
50 /*chronik_port=*/8331,
51 /*chronik_electrum_port=*/50002);
52 }
53
54 if (chain == CBaseChainParams::TESTNET) {
55 return std::make_unique<CBaseChainParams>(
56 "testnet3",
57 /*rpc_port=*/18332, 18334,
58 /*chronik_port=*/18331,
59 /*chronik_electrum_port=*/60002);
60 }
61
62 if (chain == CBaseChainParams::REGTEST) {
63 return std::make_unique<CBaseChainParams>(
64 "regtest", /*rpc_port=*/18443, 18445,
65 /*chronik_port=*/18442,
66 /*chronik_electrum_port=*/60103);
67 }
68
69 throw std::runtime_error(
70 strprintf("%s: Unknown chain %s.", __func__, chain));
71}
72
73void SelectBaseParams(const std::string &chain) {
76}
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
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
Definition: args.cpp:620
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)
#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())