28 if (!
args.GetArgs(
"-signetseednode").empty()) {
29 options.
seeds.emplace(
args.GetArgs(
"-signetseednode"));
31 if (!
args.GetArgs(
"-signetchallenge").empty()) {
32 const auto signet_challenge =
args.GetArgs(
"-signetchallenge");
33 if (signet_challenge.size() != 1) {
34 throw std::runtime_error(
"-signetchallenge cannot be multiple values.");
38 throw std::runtime_error(
strprintf(
"-signetchallenge must be hex, not '%s'.", signet_challenge[0]));
46 if (
auto value =
args.GetBoolArg(
"-fastprune")) options.
fastprune = *value;
49 for (
const std::string& arg :
args.GetArgs(
"-testactivationheight")) {
50 const auto found{arg.find(
'@')};
51 if (found == std::string::npos) {
52 throw std::runtime_error(
strprintf(
"Invalid format (%s) for -testactivationheight=name@height.", arg));
55 const auto value{arg.substr(found + 1)};
57 if (!height || *height < 0 || *height >= std::numeric_limits<int>::max()) {
58 throw std::runtime_error(
strprintf(
"Invalid height value (%s) for -testactivationheight=name@height.", arg));
61 const auto deployment_name{arg.substr(0, found)};
65 throw std::runtime_error(
strprintf(
"Invalid name (%s) for -testactivationheight=name@height.", arg));
69 for (
const std::string& strDeployment :
args.GetArgs(
"-vbparams")) {
70 std::vector<std::string> vDeploymentParams =
SplitString(strDeployment,
':');
71 if (vDeploymentParams.size() < 3 || 4 < vDeploymentParams.size()) {
72 throw std::runtime_error(
"Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
77 throw std::runtime_error(
strprintf(
"Invalid nStartTime (%s)", vDeploymentParams[1]));
82 throw std::runtime_error(
strprintf(
"Invalid nTimeout (%s)", vDeploymentParams[2]));
85 if (vDeploymentParams.size() >= 4) {
87 if (!min_activation_height) {
88 throw std::runtime_error(
strprintf(
"Invalid min_activation_height (%s)", vDeploymentParams[3]));
99 LogInfo(
"Setting version bits activation parameters for %s to start=%ld, timeout=%ld, min_activation_height=%d",
105 throw std::runtime_error(
strprintf(
"Invalid deployment (%s)", vDeploymentParams[0]));
bool HasTestOption(const ArgsManager &args, const std::string &test_option)
Checks if a particular test option is present in -test command-line arg options.
std::vector< std::string > SplitString(std::string_view str, char sep)
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const ChainType chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
static std::unique_ptr< const CChainParams > globalChainParams
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
const CChainParams & Params()
Return the currently selected parameters.
void ReadSigNetArgs(const ArgsManager &args, CChainParams::SigNetOptions &options)
void ReadRegTestArgs(const ArgsManager &args, CChainParams::RegTestOptions &options)
void SelectBaseParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
static std::unique_ptr< const CChainParams > Main()
static std::unique_ptr< const CChainParams > RegTest(const RegTestOptions &options)
static std::unique_ptr< const CChainParams > TestNet()
static std::unique_ptr< const CChainParams > TestNet4()
static std::unique_ptr< const CChainParams > SigNet(const SigNetOptions &options)
std::optional< Consensus::BuriedDeployment > GetBuriedDeployment(const std::string_view name)
const std::array< VBDeploymentInfo, Consensus::MAX_VERSION_BITS_DEPLOYMENTS > VersionBitsDeploymentInfo
@ MAX_VERSION_BITS_DEPLOYMENTS
std::vector< std::string > SplitString(std::string_view str, char sep)
std::optional< T > ToIntegral(std::string_view str, size_t base=10)
Convert string to integral type T.
RegTestOptions holds configurations for creating a regtest CChainParams.
std::unordered_map< Consensus::DeploymentPos, VersionBitsParameters > version_bits_parameters
std::unordered_map< Consensus::BuriedDeployment, int > activation_heights
SigNetOptions holds configurations for creating a signet CChainParams.
std::optional< std::vector< uint8_t > > challenge
std::optional< std::vector< std::string > > seeds
VersionBitsParameters holds activation parameters.
int min_activation_height
std::optional< std::vector< Byte > > TryParseHex(std::string_view str)
Parse the hex string into bytes (uint8_t or std::byte).