Bitcoin ABC 0.31.6
P2P Digital Currency
chainparams.cpp
Go to the documentation of this file.
1// Copyright (c) 2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Copyright (c) 2017-2020 The Bitcoin developers
4// Distributed under the MIT software license, see the accompanying
5// file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
7#include <chainparams.h>
8
9#include <chainparamsbase.h>
10#include <common/args.h>
11#include <consensus/merkle.h>
12#include <currencyunit.h>
13#include <logging.h>
14#include <tinyformat.h>
15#include <util/chaintype.h>
16
17#include <cassert>
18
19static std::unique_ptr<const CChainParams> globalChainParams;
20
23 return *globalChainParams;
24}
25
26void ReadChainArgs(const ArgsManager &args,
28 options.ecash = args.GetBoolArg("-ecash", DEFAULT_ECASH);
29 // Only relevant for REGTEST
30 options.fastprune = args.GetBoolArg("-fastprune", false);
31}
32
33std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager &args,
34 const ChainType chain) {
35 auto opts = CChainParams::ChainOptions{};
36 ReadChainArgs(args, opts);
37 switch (chain) {
38 case ChainType::MAIN:
39 return CChainParams::Main(opts);
41 return CChainParams::TestNet(opts);
42 case ChainType::REGTEST: {
43 return CChainParams::RegTest(opts);
44 }
45 }
46 throw std::invalid_argument(
47 strprintf("%s: Invalid ChainType value", __func__));
48}
49
50void SelectParams(const ChainType chain) {
51 SelectBaseParams(chain);
53}
ArgsManager gArgs
Definition: args.cpp:40
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const ChainType chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
Definition: chainparams.cpp:33
void ReadChainArgs(const ArgsManager &args, CChainParams::ChainOptions &options)
Definition: chainparams.cpp:26
static std::unique_ptr< const CChainParams > globalChainParams
Definition: chainparams.cpp:19
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given BIP70 chain name.
Definition: chainparams.cpp:50
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:21
void SelectBaseParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain.
ChainType
Definition: chaintype.h:11
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: args.cpp:525
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:86
static std::unique_ptr< const CChainParams > TestNet(const ChainOptions &options)
static std::unique_ptr< const CChainParams > RegTest(const ChainOptions &options)
static std::unique_ptr< const CChainParams > Main(const ChainOptions &options)
constexpr bool DEFAULT_ECASH
Definition: currencyunit.h:10
#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())