mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge bitcoin/bitcoin#27491: refactor: Move chain constants to the util library
d168458d1f
scripted-diff: Remove unused chainparamsbase includes (TheCharlatan)e9ee8aaf3a
Add missing definitions in prep for scripted diff (TheCharlatan)ba8fc7d788
refactor: Replace string chain name constants with ChainTypes (TheCharlatan)401453df41
refactor: Introduce ChainType getters for ArgsManager (TheCharlatan)bfc21c31b2
refactor: Create chaintype files (TheCharlatan) Pull request description: This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". It is also a follow up to #26177. It replaces pull request https://github.com/bitcoin/bitcoin/pull/27294, which just moved the constants to a new file, but did not re-declare them as enums. The code move of the chain name constants out of the `chainparamsbase` to their own separate header allows the kernel `chainparams` to no longer include `chainparamsbase`. The `chainparamsbase` contain references to the `ArgsManager` and networking related options that should not belong to the kernel library. Besides this move, the constants are re-declared as enums with helper functions facilitating string conversions. ACKs for top commit: ryanofsky: Code review ACKd168458d1f
. Just suggested changes since last review. Tree-SHA512: ac2fbe5cbbab4f52eae1e30af1f16700b6589eb4764c328a151a712adfc37f326cc94a65c385534c57d4bc92cc1a13bf1777d92bc924a20dbb30440e7380b316
This commit is contained in:
commit
fc06881f13
86 changed files with 402 additions and 254 deletions
|
@ -280,6 +280,7 @@ BITCOIN_CORE_H = \
|
|||
util/bip32.h \
|
||||
util/bitdeque.h \
|
||||
util/bytevectorhash.h \
|
||||
util/chaintype.h \
|
||||
util/check.h \
|
||||
util/epochguard.h \
|
||||
util/error.h \
|
||||
|
@ -707,6 +708,7 @@ libbitcoin_util_a_SOURCES = \
|
|||
util/asmap.cpp \
|
||||
util/bip32.cpp \
|
||||
util/bytevectorhash.cpp \
|
||||
util/chaintype.cpp \
|
||||
util/check.cpp \
|
||||
util/error.cpp \
|
||||
util/exception.cpp \
|
||||
|
@ -956,6 +958,7 @@ libbitcoinkernel_la_SOURCES = \
|
|||
txdb.cpp \
|
||||
txmempool.cpp \
|
||||
uint256.cpp \
|
||||
util/chaintype.cpp \
|
||||
util/check.cpp \
|
||||
util/exception.cpp \
|
||||
util/fs.cpp \
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <common/args.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <streams.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
// These are the two major time-sinks which happen after we have fully received
|
||||
|
@ -36,7 +37,7 @@ static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
|
|||
stream.write({&a, 1}); // Prevent compaction
|
||||
|
||||
ArgsManager bench_args;
|
||||
const auto chainParams = CreateChainParams(bench_args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(bench_args, ChainType::MAIN);
|
||||
|
||||
bench.unit("block").run([&] {
|
||||
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <bench/data.h>
|
||||
#include <chainparams.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
/**
|
||||
|
@ -22,7 +23,7 @@
|
|||
*/
|
||||
static void LoadExternalBlockFile(benchmark::Bench& bench)
|
||||
{
|
||||
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN)};
|
||||
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
|
||||
|
||||
// Create a single block as in the blocks files (magic bytes, block size,
|
||||
// block data) as a stream object.
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <bench/bench.h>
|
||||
#include <logging.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
// All but 2 of the benchmarks should have roughly similar performance:
|
||||
//
|
||||
|
@ -18,7 +19,7 @@ static void Logging(benchmark::Bench& bench, const std::vector<const char*>& ext
|
|||
LogInstance().DisableCategory(BCLog::LogFlags::ALL);
|
||||
|
||||
TestingSetup test_setup{
|
||||
CBaseChainParams::REGTEST,
|
||||
ChainType::REGTEST,
|
||||
extra_args,
|
||||
};
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <policy/policy.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <vector>
|
||||
|
@ -88,7 +89,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
|
|||
childTxs = static_cast<int>(bench.complexityN());
|
||||
}
|
||||
std::vector<CTransactionRef> ordered_coins = CreateOrderedCoins(det_rand, childTxs, /*min_ancestors=*/1);
|
||||
const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN);
|
||||
const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN);
|
||||
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
|
||||
LOCK2(cs_main, pool.cs);
|
||||
bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
|
||||
|
@ -103,7 +104,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
|
|||
static void MempoolCheck(benchmark::Bench& bench)
|
||||
{
|
||||
FastRandomContext det_rand{true};
|
||||
auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(CBaseChainParams::REGTEST, {"-checkmempool=1"});
|
||||
auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(ChainType::REGTEST, {"-checkmempool=1"});
|
||||
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
|
||||
LOCK2(cs_main, pool.cs);
|
||||
testing_setup->PopulateMempool(det_rand, 400, true);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <rpc/blockchain.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <univalue.h>
|
||||
|
@ -15,7 +16,7 @@
|
|||
namespace {
|
||||
|
||||
struct TestBlockAndIndex {
|
||||
const std::unique_ptr<const TestingSetup> testing_setup{MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN)};
|
||||
const std::unique_ptr<const TestingSetup> testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
|
||||
CBlock block{};
|
||||
uint256 blockHash{};
|
||||
CBlockIndex blockindex{};
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <bench/bench.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <kernel/cs_main.h>
|
||||
#include <kernel/mempool_entry.h>
|
||||
#include <rpc/mempool.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
|
@ -21,7 +21,7 @@ static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& poo
|
|||
|
||||
static void RpcMempool(benchmark::Bench& bench)
|
||||
{
|
||||
const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(CBaseChainParams::MAIN);
|
||||
const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(ChainType::MAIN);
|
||||
CTxMemPool& pool = *Assert(testing_setup->m_node.mempool);
|
||||
LOCK2(cs_main, pool.cs);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <node/chainstate.h>
|
||||
#include <scheduler.h>
|
||||
#include <script/sigcache.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/thread.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
@ -52,7 +53,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
|
||||
// SETUP: Misc Globals
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
SelectParams(ChainType::MAIN);
|
||||
auto chainparams = CChainParams::Main();
|
||||
|
||||
kernel::Context kernel_context{};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <rpc/request.h>
|
||||
#include <tinyformat.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/exception.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
|
@ -73,10 +74,10 @@ static void SetupCliArgs(ArgsManager& argsman)
|
|||
{
|
||||
SetupHelpOptions(argsman);
|
||||
|
||||
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
|
||||
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
|
||||
const auto signetBaseParams = CreateBaseChainParams(CBaseChainParams::SIGNET);
|
||||
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);
|
||||
const auto defaultBaseParams = CreateBaseChainParams(ChainType::MAIN);
|
||||
const auto testnetBaseParams = CreateBaseChainParams(ChainType::TESTNET);
|
||||
const auto signetBaseParams = CreateBaseChainParams(ChainType::SIGNET);
|
||||
const auto regtestBaseParams = CreateBaseChainParams(ChainType::REGTEST);
|
||||
|
||||
argsman.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
argsman.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
|
@ -174,7 +175,7 @@ static int AppInitRPC(int argc, char* argv[])
|
|||
}
|
||||
// Check for chain settings (BaseParams() calls are only valid after this clause)
|
||||
try {
|
||||
SelectBaseParams(gArgs.GetChainName());
|
||||
SelectBaseParams(gArgs.GetChainType());
|
||||
} catch (const std::exception& e) {
|
||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||
return EXIT_FAILURE;
|
||||
|
@ -426,10 +427,16 @@ private:
|
|||
std::vector<Peer> m_peers;
|
||||
std::string ChainToString() const
|
||||
{
|
||||
if (gArgs.GetChainName() == CBaseChainParams::TESTNET) return " testnet";
|
||||
if (gArgs.GetChainName() == CBaseChainParams::SIGNET) return " signet";
|
||||
if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest";
|
||||
return "";
|
||||
switch (gArgs.GetChainType()) {
|
||||
case ChainType::TESTNET:
|
||||
return " testnet";
|
||||
case ChainType::SIGNET:
|
||||
return " signet";
|
||||
case ChainType::REGTEST:
|
||||
return " regtest";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
std::string PingTimeToString(double seconds) const
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <config/bitcoin-config.h>
|
||||
#endif
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <clientversion.h>
|
||||
#include <coins.h>
|
||||
#include <common/args.h>
|
||||
|
@ -91,7 +92,7 @@ static int AppInitRawTx(int argc, char* argv[])
|
|||
|
||||
// Check for chain settings (Params() calls are only valid after this clause)
|
||||
try {
|
||||
SelectParams(gArgs.GetChainName());
|
||||
SelectParams(gArgs.GetChainType());
|
||||
} catch (const std::exception& e) {
|
||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -75,7 +75,7 @@ static int AppInitUtil(ArgsManager& args, int argc, char* argv[])
|
|||
|
||||
// Check for chain settings (Params() calls are only valid after this clause)
|
||||
try {
|
||||
SelectParams(args.GetChainName());
|
||||
SelectParams(args.GetChainType());
|
||||
} catch (const std::exception& e) {
|
||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -91,7 +91,7 @@ static std::optional<int> WalletAppInit(ArgsManager& args, int argc, char* argv[
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
// Check for chain settings (Params() calls are only valid after this clause)
|
||||
SelectParams(args.GetChainName());
|
||||
SelectParams(args.GetChainType());
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <chainparams.h>
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <chainparamsseeds.h>
|
||||
#include <common/args.h>
|
||||
#include <consensus/merkle.h>
|
||||
|
@ -12,6 +13,7 @@
|
|||
#include <hash.h> // for signet block challenge hash
|
||||
#include <logging.h>
|
||||
#include <script/interpreter.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/string.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -97,26 +99,29 @@ const CChainParams &Params() {
|
|||
return *globalChainParams;
|
||||
}
|
||||
|
||||
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain)
|
||||
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const ChainType chain)
|
||||
{
|
||||
if (chain == CBaseChainParams::MAIN) {
|
||||
switch (chain) {
|
||||
case ChainType::MAIN:
|
||||
return CChainParams::Main();
|
||||
} else if (chain == CBaseChainParams::TESTNET) {
|
||||
case ChainType::TESTNET:
|
||||
return CChainParams::TestNet();
|
||||
} else if (chain == CBaseChainParams::SIGNET) {
|
||||
case ChainType::SIGNET: {
|
||||
auto opts = CChainParams::SigNetOptions{};
|
||||
ReadSigNetArgs(args, opts);
|
||||
return CChainParams::SigNet(opts);
|
||||
} else if (chain == CBaseChainParams::REGTEST) {
|
||||
}
|
||||
case ChainType::REGTEST: {
|
||||
auto opts = CChainParams::RegTestOptions{};
|
||||
ReadRegTestArgs(args, opts);
|
||||
return CChainParams::RegTest(opts);
|
||||
}
|
||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
||||
}
|
||||
throw std::invalid_argument(strprintf("%s: Invalid ChainType value", __func__));
|
||||
}
|
||||
|
||||
void SelectParams(const std::string& network)
|
||||
void SelectParams(const ChainType chain)
|
||||
{
|
||||
SelectBaseParams(network);
|
||||
globalChainParams = CreateChainParams(gArgs, network);
|
||||
SelectBaseParams(chain);
|
||||
globalChainParams = CreateChainParams(gArgs, chain);
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
#include <kernel/chainparams.h>
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <consensus/params.h>
|
||||
#include <netaddress.h>
|
||||
#include <primitives/block.h>
|
||||
#include <protocol.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/hash_type.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -21,12 +21,14 @@
|
|||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class ArgsManager;
|
||||
|
||||
/**
|
||||
* Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
|
||||
* @returns a CChainParams* of the chosen chain.
|
||||
* @throws a std::runtime_error if the chain is not supported.
|
||||
*/
|
||||
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain);
|
||||
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const ChainType chain);
|
||||
|
||||
/**
|
||||
* Return the currently selected parameters. This won't change after app
|
||||
|
@ -38,6 +40,6 @@ const CChainParams &Params();
|
|||
* Sets the params returned by Params() to those for the given chain name.
|
||||
* @throws std::runtime_error when the chain is not supported.
|
||||
*/
|
||||
void SelectParams(const std::string& chain);
|
||||
void SelectParams(const ChainType chain);
|
||||
|
||||
#endif // BITCOIN_CHAINPARAMS_H
|
||||
|
|
|
@ -7,14 +7,10 @@
|
|||
|
||||
#include <common/args.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
const std::string CBaseChainParams::MAIN = "main";
|
||||
const std::string CBaseChainParams::TESTNET = "test";
|
||||
const std::string CBaseChainParams::SIGNET = "signet";
|
||||
const std::string CBaseChainParams::REGTEST = "regtest";
|
||||
|
||||
void SetupChainParamsBaseOptions(ArgsManager& argsman)
|
||||
{
|
||||
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
|
@ -40,22 +36,23 @@ const CBaseChainParams& BaseParams()
|
|||
* Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have
|
||||
* been chosen arbitrarily to keep ranges of used ports tight.
|
||||
*/
|
||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain)
|
||||
{
|
||||
if (chain == CBaseChainParams::MAIN) {
|
||||
switch (chain) {
|
||||
case ChainType::MAIN:
|
||||
return std::make_unique<CBaseChainParams>("", 8332, 8334);
|
||||
} else if (chain == CBaseChainParams::TESTNET) {
|
||||
case ChainType::TESTNET:
|
||||
return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334);
|
||||
} else if (chain == CBaseChainParams::SIGNET) {
|
||||
case ChainType::SIGNET:
|
||||
return std::make_unique<CBaseChainParams>("signet", 38332, 38334);
|
||||
} else if (chain == CBaseChainParams::REGTEST) {
|
||||
case ChainType::REGTEST:
|
||||
return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
|
||||
}
|
||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
||||
throw std::invalid_argument(strprintf("%s: Invalid ChainType value", __func__));
|
||||
}
|
||||
|
||||
void SelectBaseParams(const std::string& chain)
|
||||
void SelectBaseParams(const ChainType chain)
|
||||
{
|
||||
globalChainBaseParams = CreateBaseChainParams(chain);
|
||||
gArgs.SelectConfigNetwork(chain);
|
||||
gArgs.SelectConfigNetwork(ChainTypeToString(chain));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef BITCOIN_CHAINPARAMSBASE_H
|
||||
#define BITCOIN_CHAINPARAMSBASE_H
|
||||
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -17,14 +19,6 @@ class ArgsManager;
|
|||
class CBaseChainParams
|
||||
{
|
||||
public:
|
||||
///@{
|
||||
/** Chain name strings */
|
||||
static const std::string MAIN;
|
||||
static const std::string TESTNET;
|
||||
static const std::string SIGNET;
|
||||
static const std::string REGTEST;
|
||||
///@}
|
||||
|
||||
const std::string& DataDir() const { return strDataDir; }
|
||||
uint16_t RPCPort() const { return m_rpc_port; }
|
||||
uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; }
|
||||
|
@ -44,7 +38,7 @@ private:
|
|||
* @returns a CBaseChainParams* of the chosen chain.
|
||||
* @throws a std::runtime_error if the chain is not supported.
|
||||
*/
|
||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain);
|
||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain);
|
||||
|
||||
/**
|
||||
*Set the arguments for chainparams
|
||||
|
@ -57,7 +51,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman);
|
|||
*/
|
||||
const CBaseChainParams& BaseParams();
|
||||
|
||||
/** Sets the params returned by Params() to those for the given network. */
|
||||
void SelectBaseParams(const std::string& chain);
|
||||
/** Sets the params returned by Params() to those for the given chain. */
|
||||
void SelectBaseParams(const ChainType chain);
|
||||
|
||||
#endif // BITCOIN_CHAINPARAMSBASE_H
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/fs_helpers.h>
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
const char * const BITCOIN_CONF_FILENAME = "bitcoin.conf";
|
||||
const char * const BITCOIN_SETTINGS_FILENAME = "settings.json";
|
||||
|
@ -141,7 +143,7 @@ std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
|
|||
if (m_network.empty()) return std::set<std::string> {};
|
||||
|
||||
// if it's okay to use the default section for this network, don't worry
|
||||
if (m_network == CBaseChainParams::MAIN) return std::set<std::string> {};
|
||||
if (m_network == ChainTypeToString(ChainType::MAIN)) return std::set<std::string> {};
|
||||
|
||||
for (const auto& arg : m_network_only_args) {
|
||||
if (OnlyHasDefaultSectionSetting(m_settings, m_network, SettingName(arg))) {
|
||||
|
@ -155,10 +157,10 @@ std::list<SectionInfo> ArgsManager::GetUnrecognizedSections() const
|
|||
{
|
||||
// Section names to be recognized in the config file.
|
||||
static const std::set<std::string> available_sections{
|
||||
CBaseChainParams::REGTEST,
|
||||
CBaseChainParams::SIGNET,
|
||||
CBaseChainParams::TESTNET,
|
||||
CBaseChainParams::MAIN
|
||||
ChainTypeToString(ChainType::REGTEST),
|
||||
ChainTypeToString(ChainType::SIGNET),
|
||||
ChainTypeToString(ChainType::TESTNET),
|
||||
ChainTypeToString(ChainType::MAIN),
|
||||
};
|
||||
|
||||
LOCK(cs_args);
|
||||
|
@ -443,7 +445,7 @@ util::SettingsValue ArgsManager::GetPersistentSetting(const std::string& name) c
|
|||
{
|
||||
LOCK(cs_args);
|
||||
return util::GetSetting(m_settings, m_network, name, !UseDefaultSection("-" + name),
|
||||
/*ignore_nonpersistent=*/true, /*get_chain_name=*/false);
|
||||
/*ignore_nonpersistent=*/true, /*get_chain_type=*/false);
|
||||
}
|
||||
|
||||
bool ArgsManager::IsArgNegated(const std::string& strArg) const
|
||||
|
@ -717,39 +719,53 @@ fs::path ArgsManager::GetConfigFilePath() const
|
|||
return GetConfigFile(*this, GetPathArg("-conf", BITCOIN_CONF_FILENAME));
|
||||
}
|
||||
|
||||
std::string ArgsManager::GetChainName() const
|
||||
ChainType ArgsManager::GetChainType() const
|
||||
{
|
||||
std::variant<ChainType, std::string> arg = GetChainArg();
|
||||
if (auto* parsed = std::get_if<ChainType>(&arg)) return *parsed;
|
||||
throw std::runtime_error(strprintf("Unknown chain %s.", std::get<std::string>(arg)));
|
||||
}
|
||||
|
||||
std::string ArgsManager::GetChainTypeString() const
|
||||
{
|
||||
auto arg = GetChainArg();
|
||||
if (auto* parsed = std::get_if<ChainType>(&arg)) return ChainTypeToString(*parsed);
|
||||
return std::get<std::string>(arg);
|
||||
}
|
||||
|
||||
std::variant<ChainType, std::string> ArgsManager::GetChainArg() const
|
||||
{
|
||||
auto get_net = [&](const std::string& arg) {
|
||||
LOCK(cs_args);
|
||||
util::SettingsValue value = util::GetSetting(m_settings, /* section= */ "", SettingName(arg),
|
||||
/* ignore_default_section_config= */ false,
|
||||
/*ignore_nonpersistent=*/false,
|
||||
/* get_chain_name= */ true);
|
||||
/* get_chain_type= */ true);
|
||||
return value.isNull() ? false : value.isBool() ? value.get_bool() : InterpretBool(value.get_str());
|
||||
};
|
||||
|
||||
const bool fRegTest = get_net("-regtest");
|
||||
const bool fSigNet = get_net("-signet");
|
||||
const bool fTestNet = get_net("-testnet");
|
||||
const bool is_chain_arg_set = IsArgSet("-chain");
|
||||
const auto chain_arg = GetArg("-chain");
|
||||
|
||||
if ((int)is_chain_arg_set + (int)fRegTest + (int)fSigNet + (int)fTestNet > 1) {
|
||||
if ((int)chain_arg.has_value() + (int)fRegTest + (int)fSigNet + (int)fTestNet > 1) {
|
||||
throw std::runtime_error("Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.");
|
||||
}
|
||||
if (fRegTest)
|
||||
return CBaseChainParams::REGTEST;
|
||||
if (fSigNet) {
|
||||
return CBaseChainParams::SIGNET;
|
||||
if (chain_arg) {
|
||||
if (auto parsed = ChainTypeFromString(*chain_arg)) return *parsed;
|
||||
// Not a known string, so return original string
|
||||
return *chain_arg;
|
||||
}
|
||||
if (fTestNet)
|
||||
return CBaseChainParams::TESTNET;
|
||||
|
||||
return GetArg("-chain", CBaseChainParams::MAIN);
|
||||
if (fRegTest) return ChainType::REGTEST;
|
||||
if (fSigNet) return ChainType::SIGNET;
|
||||
if (fTestNet) return ChainType::TESTNET;
|
||||
return ChainType::MAIN;
|
||||
}
|
||||
|
||||
bool ArgsManager::UseDefaultSection(const std::string& arg) const
|
||||
{
|
||||
return m_network == CBaseChainParams::MAIN || m_network_only_args.count(arg) == 0;
|
||||
return m_network == ChainTypeToString(ChainType::MAIN) || m_network_only_args.count(arg) == 0;
|
||||
}
|
||||
|
||||
util::SettingsValue ArgsManager::GetSetting(const std::string& arg) const
|
||||
|
@ -757,7 +773,7 @@ util::SettingsValue ArgsManager::GetSetting(const std::string& arg) const
|
|||
LOCK(cs_args);
|
||||
return util::GetSetting(
|
||||
m_settings, m_network, SettingName(arg), !UseDefaultSection(arg),
|
||||
/*ignore_nonpersistent=*/false, /*get_chain_name=*/false);
|
||||
/*ignore_nonpersistent=*/false, /*get_chain_type=*/false);
|
||||
}
|
||||
|
||||
std::vector<util::SettingsValue> ArgsManager::GetSettingsList(const std::string& arg) const
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <compat/compat.h>
|
||||
#include <sync.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/settings.h>
|
||||
|
||||
|
@ -17,6 +18,7 @@
|
|||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
class ArgsManager;
|
||||
|
@ -324,9 +326,17 @@ protected:
|
|||
|
||||
/**
|
||||
* Returns the appropriate chain name from the program arguments.
|
||||
* @return CBaseChainParams::MAIN by default; raises runtime error if an invalid combination is given.
|
||||
* @return ChainType::MAIN by default; raises runtime error if an invalid
|
||||
* combination, or unknown chain is given.
|
||||
*/
|
||||
std::string GetChainName() const;
|
||||
ChainType GetChainType() const;
|
||||
|
||||
/**
|
||||
* Returns the appropriate chain name string from the program arguments.
|
||||
* @return ChainType::MAIN string by default; raises runtime error if an
|
||||
* invalid combination is given.
|
||||
*/
|
||||
std::string GetChainTypeString() const;
|
||||
|
||||
/**
|
||||
* Add argument
|
||||
|
@ -411,6 +421,14 @@ private:
|
|||
*/
|
||||
const fs::path& GetDataDir(bool net_specific) const;
|
||||
|
||||
/**
|
||||
* Return -regtest/-signet/-testnet/-chain= setting as a ChainType enum if a
|
||||
* recognized chain name was set, or as a string if an unrecognized chain
|
||||
* name was set. Raise an exception if an invalid combination of flags was
|
||||
* provided.
|
||||
*/
|
||||
std::variant<ChainType, std::string> GetChainArg() const;
|
||||
|
||||
// Helper function for LogArgs().
|
||||
void logArgsPrefix(
|
||||
const std::string& prefix,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/settings.h>
|
||||
#include <util/string.h>
|
||||
|
@ -152,7 +153,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
|||
}
|
||||
}
|
||||
if (use_conf_file) {
|
||||
std::string chain_id = GetChainName();
|
||||
std::string chain_id = GetChainTypeString();
|
||||
std::vector<std::string> conf_file_names;
|
||||
|
||||
auto add_includes = [&](const std::string& network, size_t skip = 0) {
|
||||
|
@ -191,7 +192,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
|||
conf_file_names.clear();
|
||||
add_includes(chain_id, /* skip= */ chain_includes);
|
||||
add_includes({}, /* skip= */ default_includes);
|
||||
std::string chain_id_final = GetChainName();
|
||||
std::string chain_id_final = GetChainTypeString();
|
||||
if (chain_id_final != chain_id) {
|
||||
// Also warn about recursive includeconf for the chain that was specified in one of the includeconfs
|
||||
add_includes(chain_id_final);
|
||||
|
|
|
@ -26,7 +26,7 @@ std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn setting
|
|||
}
|
||||
|
||||
// Check for chain settings (Params() calls are only valid after this clause)
|
||||
SelectParams(args.GetChainName());
|
||||
SelectParams(args.GetChainType());
|
||||
|
||||
// Create datadir if it does not exist.
|
||||
const auto base_path{args.GetDataDirBase()};
|
||||
|
|
26
src/init.cpp
26
src/init.cpp
|
@ -18,6 +18,7 @@
|
|||
#include <blockfilter.h>
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <common/args.h>
|
||||
#include <consensus/amount.h>
|
||||
#include <deploymentstatus.h>
|
||||
|
@ -69,6 +70,7 @@
|
|||
#include <txdb.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/asmap.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/fs_helpers.h>
|
||||
|
@ -408,14 +410,14 @@ void SetupServerArgs(ArgsManager& argsman)
|
|||
|
||||
init::AddLoggingArgs(argsman);
|
||||
|
||||
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
|
||||
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
|
||||
const auto signetBaseParams = CreateBaseChainParams(CBaseChainParams::SIGNET);
|
||||
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);
|
||||
const auto defaultChainParams = CreateChainParams(argsman, CBaseChainParams::MAIN);
|
||||
const auto testnetChainParams = CreateChainParams(argsman, CBaseChainParams::TESTNET);
|
||||
const auto signetChainParams = CreateChainParams(argsman, CBaseChainParams::SIGNET);
|
||||
const auto regtestChainParams = CreateChainParams(argsman, CBaseChainParams::REGTEST);
|
||||
const auto defaultBaseParams = CreateBaseChainParams(ChainType::MAIN);
|
||||
const auto testnetBaseParams = CreateBaseChainParams(ChainType::TESTNET);
|
||||
const auto signetBaseParams = CreateBaseChainParams(ChainType::SIGNET);
|
||||
const auto regtestBaseParams = CreateBaseChainParams(ChainType::REGTEST);
|
||||
const auto defaultChainParams = CreateChainParams(argsman, ChainType::MAIN);
|
||||
const auto testnetChainParams = CreateChainParams(argsman, ChainType::TESTNET);
|
||||
const auto signetChainParams = CreateChainParams(argsman, ChainType::SIGNET);
|
||||
const auto regtestChainParams = CreateChainParams(argsman, ChainType::REGTEST);
|
||||
|
||||
// Hidden Options
|
||||
std::vector<std::string> hidden_args = {
|
||||
|
@ -844,14 +846,14 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
|
|||
|
||||
// Error if network-specific options (-addnode, -connect, etc) are
|
||||
// specified in default section of config file, but not overridden
|
||||
// on the command line or in this network's section of the config file.
|
||||
std::string network = args.GetChainName();
|
||||
if (network == CBaseChainParams::SIGNET) {
|
||||
// on the command line or in this chain's section of the config file.
|
||||
ChainType chain = args.GetChainType();
|
||||
if (chain == ChainType::SIGNET) {
|
||||
LogPrintf("Signet derived magic (message start): %s\n", HexStr(chainparams.MessageStart()));
|
||||
}
|
||||
bilingual_str errors;
|
||||
for (const auto& arg : args.GetUnsuitableSectionOnlyArgs()) {
|
||||
errors += strprintf(_("Config setting for %s only applied on %s network when in [%s] section.") + Untranslated("\n"), arg, network, network);
|
||||
errors += strprintf(_("Config setting for %s only applied on %s network when in [%s] section.") + Untranslated("\n"), arg, ChainTypeToString(chain), ChainTypeToString(chain));
|
||||
}
|
||||
|
||||
if (!errors.empty()) {
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
#include <consensus/merkle.h>
|
||||
#include <consensus/params.h>
|
||||
#include <hash.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <logging.h>
|
||||
#include <primitives/block.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <script/interpreter.h>
|
||||
#include <script/script.h>
|
||||
#include <uint256.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -70,7 +70,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits
|
|||
class CMainParams : public CChainParams {
|
||||
public:
|
||||
CMainParams() {
|
||||
strNetworkID = CBaseChainParams::MAIN;
|
||||
m_chain_type = ChainType::MAIN;
|
||||
consensus.signet_blocks = false;
|
||||
consensus.signet_challenge.clear();
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
class CTestNetParams : public CChainParams {
|
||||
public:
|
||||
CTestNetParams() {
|
||||
strNetworkID = CBaseChainParams::TESTNET;
|
||||
m_chain_type = ChainType::TESTNET;
|
||||
consensus.signet_blocks = false;
|
||||
consensus.signet_challenge.clear();
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
|
@ -328,7 +328,7 @@ public:
|
|||
vSeeds = *options.seeds;
|
||||
}
|
||||
|
||||
strNetworkID = CBaseChainParams::SIGNET;
|
||||
m_chain_type = ChainType::SIGNET;
|
||||
consensus.signet_blocks = true;
|
||||
consensus.signet_challenge.assign(bin.begin(), bin.end());
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
|
@ -397,7 +397,7 @@ class CRegTestParams : public CChainParams
|
|||
public:
|
||||
explicit CRegTestParams(const RegTestOptions& opts)
|
||||
{
|
||||
strNetworkID = CBaseChainParams::REGTEST;
|
||||
m_chain_type = ChainType::REGTEST;
|
||||
consensus.signet_blocks = false;
|
||||
consensus.signet_challenge.clear();
|
||||
consensus.nSubsidyHalvingInterval = 150;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <primitives/block.h>
|
||||
#include <protocol.h>
|
||||
#include <uint256.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/hash_type.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -114,8 +115,10 @@ public:
|
|||
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
|
||||
/** Whether it is possible to mine blocks on demand (no retargeting) */
|
||||
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
|
||||
/** Return the network string */
|
||||
std::string NetworkIDString() const { return strNetworkID; }
|
||||
/** Return the chain type string */
|
||||
std::string GetChainTypeString() const { return ChainTypeToString(m_chain_type); }
|
||||
/** Return the chain type */
|
||||
ChainType GetChainType() const { return m_chain_type; }
|
||||
/** Return the list of hostnames to look up for DNS seeds */
|
||||
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
|
||||
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
||||
|
@ -172,7 +175,7 @@ protected:
|
|||
std::vector<std::string> vSeeds;
|
||||
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
||||
std::string bech32_hrp;
|
||||
std::string strNetworkID;
|
||||
ChainType m_chain_type;
|
||||
CBlock genesis;
|
||||
std::vector<uint8_t> vFixedSeeds;
|
||||
bool fDefaultConsistencyChecks;
|
||||
|
|
|
@ -239,7 +239,7 @@ public:
|
|||
std::vector<ExternalSigner> signers = {};
|
||||
const std::string command = args().GetArg("-signer", "");
|
||||
if (command == "") return {};
|
||||
ExternalSigner::Enumerate(command, signers, Params().NetworkIDString());
|
||||
ExternalSigner::Enumerate(command, signers, Params().GetChainTypeString());
|
||||
std::vector<std::unique_ptr<interfaces::ExternalSigner>> result;
|
||||
result.reserve(signers.size());
|
||||
for (auto& signer : signers) {
|
||||
|
|
|
@ -89,7 +89,7 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& argsman, con
|
|||
|
||||
mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
|
||||
if (!chainparams.IsTestChain() && !mempool_opts.require_standard) {
|
||||
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.NetworkIDString());
|
||||
return strprintf(Untranslated("acceptnonstdtxn is not currently supported for %s chain"), chainparams.GetChainTypeString());
|
||||
}
|
||||
|
||||
mempool_opts.full_rbf = argsman.GetBoolArg("-mempoolfullrbf", mempool_opts.full_rbf);
|
||||
|
|
|
@ -601,7 +601,7 @@ int GuiMain(int argc, char* argv[])
|
|||
PaymentServer::ipcParseCommandLine(argc, argv);
|
||||
#endif
|
||||
|
||||
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().NetworkIDString()));
|
||||
QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().GetChainType()));
|
||||
assert(!networkStyle.isNull());
|
||||
// Allow for separate UI settings for testnets
|
||||
QApplication::setApplicationName(networkStyle->getAppName());
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <protocol.h>
|
||||
#include <script/script.h>
|
||||
#include <script/standard.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/exception.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/fs_helpers.h>
|
||||
|
@ -503,12 +504,12 @@ bool LabelOutOfFocusEventFilter::eventFilter(QObject* watched, QEvent* event)
|
|||
#ifdef WIN32
|
||||
fs::path static StartupShortcutPath()
|
||||
{
|
||||
std::string chain = gArgs.GetChainName();
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
ChainType chain = gArgs.GetChainType();
|
||||
if (chain == ChainType::MAIN)
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
|
||||
if (chain == CBaseChainParams::TESTNET) // Remove this special case when CBaseChainParams::TESTNET = "testnet4"
|
||||
if (chain == ChainType::TESTNET) // Remove this special case when testnet CBaseChainParams::DataDir() is incremented to "testnet4"
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / fs::u8path(strprintf("Bitcoin (%s).lnk", chain));
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / fs::u8path(strprintf("Bitcoin (%s).lnk", ChainTypeToString(chain)));
|
||||
}
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
|
@ -541,7 +542,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
|||
// Start client minimized
|
||||
QString strArgs = "-min";
|
||||
// Set -testnet /-regtest options
|
||||
strArgs += QString::fromStdString(strprintf(" -chain=%s", gArgs.GetChainName()));
|
||||
strArgs += QString::fromStdString(strprintf(" -chain=%s", gArgs.GetChainTypeString()));
|
||||
|
||||
// Set the path to the shortcut target
|
||||
psl->SetPath(pszExePath);
|
||||
|
@ -586,10 +587,10 @@ fs::path static GetAutostartDir()
|
|||
|
||||
fs::path static GetAutostartFilePath()
|
||||
{
|
||||
std::string chain = gArgs.GetChainName();
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
ChainType chain = gArgs.GetChainType();
|
||||
if (chain == ChainType::MAIN)
|
||||
return GetAutostartDir() / "bitcoin.desktop";
|
||||
return GetAutostartDir() / fs::u8path(strprintf("bitcoin-%s.desktop", chain));
|
||||
return GetAutostartDir() / fs::u8path(strprintf("bitcoin-%s.desktop", ChainTypeToString(chain)));
|
||||
}
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
|
@ -629,15 +630,15 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
|||
std::ofstream optionFile{GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc};
|
||||
if (!optionFile.good())
|
||||
return false;
|
||||
std::string chain = gArgs.GetChainName();
|
||||
ChainType chain = gArgs.GetChainType();
|
||||
// Write a bitcoin.desktop file to the autostart directory:
|
||||
optionFile << "[Desktop Entry]\n";
|
||||
optionFile << "Type=Application\n";
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
if (chain == ChainType::MAIN)
|
||||
optionFile << "Name=Bitcoin\n";
|
||||
else
|
||||
optionFile << strprintf("Name=Bitcoin (%s)\n", chain);
|
||||
optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", chain);
|
||||
optionFile << strprintf("Name=Bitcoin (%s)\n", ChainTypeToString(chain));
|
||||
optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", ChainTypeToString(chain));
|
||||
optionFile << "Terminal=false\n";
|
||||
optionFile << "Hidden=false\n";
|
||||
optionFile.close();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <chainparams.h>
|
||||
#include <qt/intro.h>
|
||||
#include <qt/forms/ui_intro.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/fs.h>
|
||||
|
||||
#include <qt/guiconstants.h>
|
||||
|
@ -219,7 +220,7 @@ bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB)
|
|||
{
|
||||
/* Use selectParams here to guarantee Params() can be used by node interface */
|
||||
try {
|
||||
SelectParams(gArgs.GetChainName());
|
||||
SelectParams(gArgs.GetChainType());
|
||||
} catch (const std::exception&) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
|
||||
#include <qt/guiconstants.h>
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
static const struct {
|
||||
const char *networkId;
|
||||
const ChainType networkId;
|
||||
const char *appName;
|
||||
const int iconColorHueShift;
|
||||
const int iconColorSaturationReduction;
|
||||
} network_styles[] = {
|
||||
{"main", QAPP_APP_NAME_DEFAULT, 0, 0},
|
||||
{"test", QAPP_APP_NAME_TESTNET, 70, 30},
|
||||
{"signet", QAPP_APP_NAME_SIGNET, 35, 15},
|
||||
{"regtest", QAPP_APP_NAME_REGTEST, 160, 30},
|
||||
{ChainType::MAIN, QAPP_APP_NAME_DEFAULT, 0, 0},
|
||||
{ChainType::TESTNET, QAPP_APP_NAME_TESTNET, 70, 30},
|
||||
{ChainType::SIGNET, QAPP_APP_NAME_SIGNET, 35, 15},
|
||||
{ChainType::REGTEST, QAPP_APP_NAME_REGTEST, 160, 30},
|
||||
};
|
||||
|
||||
// titleAddText needs to be const char* for tr()
|
||||
|
@ -77,9 +77,9 @@ NetworkStyle::NetworkStyle(const QString &_appName, const int iconColorHueShift,
|
|||
trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256)));
|
||||
}
|
||||
|
||||
const NetworkStyle* NetworkStyle::instantiate(const std::string& networkId)
|
||||
const NetworkStyle* NetworkStyle::instantiate(const ChainType networkId)
|
||||
{
|
||||
std::string titleAddText = networkId == CBaseChainParams::MAIN ? "" : strprintf("[%s]", networkId);
|
||||
std::string titleAddText = networkId == ChainType::MAIN ? "" : strprintf("[%s]", ChainTypeToString(networkId));
|
||||
for (const auto& network_style : network_styles) {
|
||||
if (networkId == network_style.networkId) {
|
||||
return new NetworkStyle(
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef BITCOIN_QT_NETWORKSTYLE_H
|
||||
#define BITCOIN_QT_NETWORKSTYLE_H
|
||||
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
|
@ -14,7 +16,7 @@ class NetworkStyle
|
|||
{
|
||||
public:
|
||||
/** Get style associated with provided network id, or 0 if not known */
|
||||
static const NetworkStyle* instantiate(const std::string& networkId);
|
||||
static const NetworkStyle* instantiate(const ChainType networkId);
|
||||
|
||||
const QString &getAppName() const { return appName; }
|
||||
const QIcon &getAppIcon() const { return appIcon; }
|
||||
|
|
|
@ -744,7 +744,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
|||
ui->dataDir->setText(model->dataDir());
|
||||
ui->blocksDir->setText(model->blocksDir());
|
||||
ui->startupTime->setText(model->formatClientStartupTime());
|
||||
ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
|
||||
ui->networkName->setText(QString::fromStdString(Params().GetChainTypeString()));
|
||||
|
||||
//Setup autocomplete and attach it
|
||||
QStringList wordList;
|
||||
|
|
|
@ -73,7 +73,7 @@ void AppTests::appTests()
|
|||
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
|
||||
m_app.parameterSetup();
|
||||
QVERIFY(m_app.createOptionsModel(/*resetSettings=*/true));
|
||||
QScopedPointer<const NetworkStyle> style(NetworkStyle::instantiate(Params().NetworkIDString()));
|
||||
QScopedPointer<const NetworkStyle> style(NetworkStyle::instantiate(Params().GetChainType()));
|
||||
m_app.setupPlatformStyle();
|
||||
m_app.createWindow(style.data());
|
||||
connect(&m_app, &BitcoinApplication::windowShown, this, &AppTests::guiTests);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <qt/test/rpcnestedtests.h>
|
||||
#include <qt/test/uritests.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
#include <qt/test/addressbooktests.h>
|
||||
|
@ -57,7 +58,7 @@ int main(int argc, char* argv[])
|
|||
//
|
||||
// All tests must use their own testing setup (if needed).
|
||||
fs::create_directories([] {
|
||||
BasicTestingSetup dummy{CBaseChainParams::REGTEST};
|
||||
BasicTestingSetup dummy{ChainType::REGTEST};
|
||||
return gArgs.GetDataDirNet() / "blocks";
|
||||
}());
|
||||
|
||||
|
|
|
@ -1256,7 +1256,7 @@ RPCHelpMan getblockchaininfo()
|
|||
const CBlockIndex& tip{*CHECK_NONFATAL(active_chainstate.m_chain.Tip())};
|
||||
const int height{tip.nHeight};
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("chain", chainman.GetParams().NetworkIDString());
|
||||
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
|
||||
obj.pushKV("blocks", height);
|
||||
obj.pushKV("headers", chainman.m_best_header ? chainman.m_best_header->nHeight : -1);
|
||||
obj.pushKV("bestblockhash", tip.GetBlockHash().GetHex());
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <common/args.h>
|
||||
#include <external_signer.h>
|
||||
#include <rpc/protocol.h>
|
||||
|
@ -43,7 +42,7 @@ static RPCHelpMan enumeratesigners()
|
|||
{
|
||||
const std::string command = gArgs.GetArg("-signer", "");
|
||||
if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart bitcoind with -signer=<cmd>");
|
||||
const std::string chain = gArgs.GetChainName();
|
||||
const std::string chain = gArgs.GetChainTypeString();
|
||||
UniValue signers_res = UniValue::VARR;
|
||||
try {
|
||||
std::vector<ExternalSigner> signers;
|
||||
|
|
|
@ -435,7 +435,7 @@ static RPCHelpMan getmininginfo()
|
|||
obj.pushKV("difficulty", (double)GetDifficulty(active_chain.Tip()));
|
||||
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
|
||||
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
||||
obj.pushKV("chain", chainman.GetParams().NetworkIDString());
|
||||
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
|
||||
obj.pushKV("warnings", GetWarnings(false).original);
|
||||
return obj;
|
||||
},
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <rpc/util.h>
|
||||
#include <sync.h>
|
||||
#include <timedata.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <util/time.h>
|
||||
|
@ -354,7 +355,7 @@ static RPCHelpMan addconnection()
|
|||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
if (Params().NetworkIDString() != CBaseChainParams::REGTEST) {
|
||||
if (Params().GetChainType() != ChainType::REGTEST) {
|
||||
throw std::runtime_error("addconnection is for regression testing (-regtest mode) only.");
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <test/util/setup_common.h>
|
||||
#include <test/util/str.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
|
@ -580,7 +581,7 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
|
|||
test_args.SetNetworkOnlyArg("-ccc");
|
||||
test_args.SetNetworkOnlyArg("-h");
|
||||
|
||||
test_args.SelectConfigNetwork(CBaseChainParams::MAIN);
|
||||
test_args.SelectConfigNetwork(ChainTypeToString(ChainType::MAIN));
|
||||
BOOST_CHECK(test_args.GetArg("-d", "xxx") == "e");
|
||||
BOOST_CHECK(test_args.GetArgs("-ccc").size() == 2);
|
||||
BOOST_CHECK(test_args.GetArg("-h", "xxx") == "0");
|
||||
|
@ -637,7 +638,7 @@ BOOST_AUTO_TEST_CASE(util_GetArg)
|
|||
BOOST_CHECK_EQUAL(testArgs.GetArg("pritest4", "default"), "b");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_GetChainName)
|
||||
BOOST_AUTO_TEST_CASE(util_GetChainTypeString)
|
||||
{
|
||||
TestArgsManager test_args;
|
||||
const auto testnet = std::make_pair("-testnet", ArgsManager::ALLOW_ANY);
|
||||
|
@ -655,39 +656,39 @@ BOOST_AUTO_TEST_CASE(util_GetChainName)
|
|||
std::string error;
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "main");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "main");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "regtest");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "regtest");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_test_no_reg, error));
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
||||
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
||||
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_test_no_reg, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
||||
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||
|
||||
// check setting the network to test (and thus making
|
||||
// [test] regtest=1 potentially relevant) doesn't break things
|
||||
|
@ -695,23 +696,23 @@ BOOST_AUTO_TEST_CASE(util_GetChainName)
|
|||
|
||||
BOOST_CHECK(test_args.ParseParameters(0, (char**)argv_testnet, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_testnet, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_regtest, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
||||
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(2, (char**)argv_test_no_reg, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainName(), "test");
|
||||
BOOST_CHECK_EQUAL(test_args.GetChainTypeString(), "test");
|
||||
|
||||
BOOST_CHECK(test_args.ParseParameters(3, (char**)argv_both, error));
|
||||
test_args.ReadConfigString(testnetconf);
|
||||
BOOST_CHECK_THROW(test_args.GetChainName(), std::runtime_error);
|
||||
BOOST_CHECK_THROW(test_args.GetChainTypeString(), std::runtime_error);
|
||||
}
|
||||
|
||||
// Test different ways settings can be merged, and verify results. This test can
|
||||
|
@ -755,8 +756,8 @@ struct ArgsMergeTestingSetup : public BasicTestingSetup {
|
|||
ForEachNoDup(conf_actions, SET, SECTION_NEGATE, [&] {
|
||||
for (bool soft_set : {false, true}) {
|
||||
for (bool force_set : {false, true}) {
|
||||
for (const std::string& section : {CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET}) {
|
||||
for (const std::string& network : {CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET}) {
|
||||
for (const std::string& section : {ChainTypeToString(ChainType::MAIN), ChainTypeToString(ChainType::TESTNET), ChainTypeToString(ChainType::SIGNET)}) {
|
||||
for (const std::string& network : {ChainTypeToString(ChainType::MAIN), ChainTypeToString(ChainType::TESTNET), ChainTypeToString(ChainType::SIGNET)}) {
|
||||
for (bool net_specific : {false, true}) {
|
||||
fn(arg_actions, conf_actions, soft_set, force_set, section, network, net_specific);
|
||||
}
|
||||
|
@ -913,7 +914,7 @@ BOOST_FIXTURE_TEST_CASE(util_ArgsMerge, ArgsMergeTestingSetup)
|
|||
BOOST_CHECK_EQUAL(out_sha_hex, "d1e436c1cd510d0ec44d5205d4b4e3bee6387d316e0075c58206cb16603f3d82");
|
||||
}
|
||||
|
||||
// Similar test as above, but for ArgsManager::GetChainName function.
|
||||
// Similar test as above, but for ArgsManager::GetChainTypeString function.
|
||||
struct ChainMergeTestingSetup : public BasicTestingSetup {
|
||||
static constexpr int MAX_ACTIONS = 2;
|
||||
|
||||
|
@ -982,7 +983,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
|
|||
|
||||
desc += " || ";
|
||||
try {
|
||||
desc += parser.GetChainName();
|
||||
desc += parser.GetChainTypeString();
|
||||
} catch (const std::runtime_error& e) {
|
||||
desc += "error: ";
|
||||
desc += e.what();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <chainparams.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <node/context.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
@ -20,7 +21,7 @@ BOOST_FIXTURE_TEST_SUITE(blockmanager_tests, BasicTestingSetup)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(blockmanager_find_block_pos)
|
||||
{
|
||||
const auto params {CreateChainParams(ArgsManager{}, CBaseChainParams::MAIN)};
|
||||
const auto params {CreateChainParams(ArgsManager{}, ChainType::MAIN)};
|
||||
node::BlockManager::Options blockman_opts{
|
||||
.chainparams = *params,
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <sync.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/time.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
@ -27,9 +28,9 @@
|
|||
struct NoLockLoggingTestingSetup : public TestingSetup {
|
||||
NoLockLoggingTestingSetup()
|
||||
#ifdef DEBUG_LOCKCONTENTION
|
||||
: TestingSetup{CBaseChainParams::MAIN, /*extra_args=*/{"-debugexclude=lock"}} {}
|
||||
: TestingSetup{ChainType::MAIN, /*extra_args=*/{"-debugexclude=lock"}} {}
|
||||
#else
|
||||
: TestingSetup{CBaseChainParams::MAIN} {}
|
||||
: TestingSetup{ChainType::MAIN} {}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <test/util/setup_common.h>
|
||||
#include <time.h>
|
||||
#include <util/asmap.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
@ -34,7 +35,7 @@ int32_t GetCheckRatio()
|
|||
|
||||
void initialize_addrman()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<>(CBaseChainParams::REGTEST);
|
||||
static const auto testing_setup = MakeNoLogFileContext<>(ChainType::REGTEST);
|
||||
g_setup = testing_setup.get();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <pubkey.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
|
@ -19,7 +20,7 @@
|
|||
|
||||
void initialize_block()
|
||||
{
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(block, initialize_block)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <coins.h>
|
||||
#include <consensus/amount.h>
|
||||
#include <consensus/tx_check.h>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <addrman.h>
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <common/args.h>
|
||||
#include <net.h>
|
||||
#include <netaddress.h>
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
#include <pubkey.h>
|
||||
#include <script/descriptor.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
void initialize_descriptor_parse()
|
||||
{
|
||||
ECC_Start();
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
SelectParams(ChainType::MAIN);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(descriptor_parse, initialize_descriptor_parse)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
|
||||
|
@ -15,7 +16,7 @@
|
|||
static void initialize_headers_sync_state_fuzz()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<>(
|
||||
/*chain_name=*/CBaseChainParams::MAIN);
|
||||
/*chain_type=*/ChainType::MAIN);
|
||||
}
|
||||
|
||||
void MakeHeadersContinuous(
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <uint256.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/overflow.h>
|
||||
|
@ -42,7 +43,7 @@
|
|||
|
||||
void initialize_integer()
|
||||
{
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(integer, initialize_integer)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <key.h>
|
||||
#include <key_io.h>
|
||||
#include <outputtype.h>
|
||||
|
@ -17,6 +16,7 @@
|
|||
#include <script/standard.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
#include <cassert>
|
||||
|
@ -28,7 +28,7 @@
|
|||
void initialize_key()
|
||||
{
|
||||
ECC_Start();
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(key, initialize_key)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <chainparams.h>
|
||||
#include <key_io.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
@ -14,7 +15,7 @@
|
|||
void initialize_key_io()
|
||||
{
|
||||
ECC_Start();
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
SelectParams(ChainType::MAIN);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(key_io, initialize_key_io)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/message.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
|
@ -19,7 +20,7 @@
|
|||
void initialize_message()
|
||||
{
|
||||
ECC_Start();
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(message, initialize_message)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <net.h>
|
||||
#include <net_permissions.h>
|
||||
#include <netaddress.h>
|
||||
|
@ -16,6 +15,7 @@
|
|||
#include <test/util/net.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/asmap.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
void initialize_net()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<>(CBaseChainParams::MAIN);
|
||||
static const auto testing_setup = MakeNoLogFileContext<>(ChainType::MAIN);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(net, initialize_net)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <protocol.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
@ -18,7 +19,7 @@
|
|||
|
||||
void initialize_p2p_transport_serialization()
|
||||
{
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(p2p_transport_serialization, initialize_p2p_transport_serialization)
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
#include <rpc/client.h>
|
||||
#include <rpc/util.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
void initialize_parse_univalue()
|
||||
{
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(parse_univalue, initialize_parse_univalue)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/overflow.h>
|
||||
|
||||
|
@ -19,7 +20,7 @@
|
|||
|
||||
void initialize_pow()
|
||||
{
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
SelectParams(ChainType::MAIN);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(pow, initialize_pow)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <test/util/net.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/validation.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validationinterface.h>
|
||||
#include <version.h>
|
||||
|
||||
|
@ -57,7 +58,7 @@ void initialize_process_message()
|
|||
Assert(GetNumMsgTypes() == getAllNetMessageTypes().size()); // If this fails, add or remove the message type below
|
||||
|
||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
|
||||
/*chain_name=*/CBaseChainParams::REGTEST,
|
||||
/*chain_type=*/ChainType::REGTEST,
|
||||
/*extra_args=*/{"-txreconciliation"});
|
||||
g_setup = testing_setup.get();
|
||||
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
||||
|
|
|
@ -24,7 +24,7 @@ const TestingSetup* g_setup;
|
|||
void initialize_process_messages()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
|
||||
/*chain_name=*/CBaseChainParams::REGTEST,
|
||||
/*chain_type=*/ChainType::REGTEST,
|
||||
/*extra_args=*/{"-txreconciliation"});
|
||||
g_setup = testing_setup.get();
|
||||
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <test/util/setup_common.h>
|
||||
#include <tinyformat.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <util/time.h>
|
||||
|
@ -37,7 +38,7 @@
|
|||
|
||||
namespace {
|
||||
struct RPCFuzzTestingSetup : public TestingSetup {
|
||||
RPCFuzzTestingSetup(const std::string& chain_name, const std::vector<const char*>& extra_args) : TestingSetup{chain_name, extra_args}
|
||||
RPCFuzzTestingSetup(const ChainType chain_type, const std::vector<const char*>& extra_args) : TestingSetup{chain_type, extra_args}
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
@ -32,7 +33,7 @@
|
|||
|
||||
void initialize_script()
|
||||
{
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(script, initialize_script)
|
||||
|
|
|
@ -11,10 +11,11 @@
|
|||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
void initialize_script_format()
|
||||
{
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(script_format, initialize_script_format)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <key.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/sigcache.h>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <key.h>
|
||||
#include <psbt.h>
|
||||
#include <pubkey.h>
|
||||
|
@ -14,6 +13,7 @@
|
|||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
#include <cassert>
|
||||
|
@ -27,7 +27,7 @@
|
|||
void initialize_script_sign()
|
||||
{
|
||||
ECC_Start();
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(script_sign, initialize_script_sign)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
@ -18,7 +19,7 @@
|
|||
|
||||
void initialize_signet()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<>(CBaseChainParams::SIGNET);
|
||||
static const auto testing_setup = MakeNoLogFileContext<>(ChainType::SIGNET);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(signet, initialize_signet)
|
||||
|
|
|
@ -108,7 +108,7 @@ FUZZ_TARGET_INIT(system, initialize_system)
|
|||
(void)args_manager.GetArgs(s1);
|
||||
(void)args_manager.GetBoolArg(s1, b);
|
||||
try {
|
||||
(void)args_manager.GetChainName();
|
||||
(void)args_manager.GetChainTypeString();
|
||||
} catch (const std::runtime_error&) {
|
||||
}
|
||||
(void)args_manager.GetHelpMessage();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <streams.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/rbf.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
@ -23,7 +24,7 @@
|
|||
|
||||
void initialize_transaction()
|
||||
{
|
||||
SelectParams(CBaseChainParams::REGTEST);
|
||||
SelectParams(ChainType::REGTEST);
|
||||
}
|
||||
|
||||
FUZZ_TARGET_INIT(transaction, initialize_transaction)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#define BITCOIN_TEST_FUZZ_UTIL_H
|
||||
|
||||
#include <arith_uint256.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <coins.h>
|
||||
#include <compat/compat.h>
|
||||
#include <consensus/amount.h>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <test/util/mining.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/fs.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
@ -22,7 +23,7 @@ const std::vector<std::shared_ptr<CBlock>>* g_chain;
|
|||
|
||||
void initialize_chain()
|
||||
{
|
||||
const auto params{CreateChainParams(ArgsManager{}, CBaseChainParams::REGTEST)};
|
||||
const auto params{CreateChainParams(ArgsManager{}, ChainType::REGTEST)};
|
||||
static const auto chain{CreateBlockChain(2 * COINBASE_MATURITY, *params)};
|
||||
g_chain = &chain;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <test/util/mining.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
|
@ -21,7 +22,7 @@ FUZZ_TARGET(utxo_total_supply)
|
|||
{
|
||||
/** The testing setup that creates a chainman only (no chainstate) */
|
||||
ChainTestingSetup test_setup{
|
||||
CBaseChainParams::REGTEST,
|
||||
ChainType::REGTEST,
|
||||
{
|
||||
"-testactivationheight=bip34@2",
|
||||
},
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <kernel/mempool_persist.h>
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <node/mempool_args.h>
|
||||
#include <node/mempool_persist_args.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <common/args.h>
|
||||
#include <consensus/params.h>
|
||||
#include <primitives/block.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <versionbits.h>
|
||||
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
|
@ -104,7 +105,7 @@ std::unique_ptr<const CChainParams> g_params;
|
|||
void initialize()
|
||||
{
|
||||
// this is actually comparatively slow, so only do it once
|
||||
g_params = CreateChainParams(ArgsManager{}, CBaseChainParams::MAIN);
|
||||
g_params = CreateChainParams(ArgsManager{}, ChainType::MAIN);
|
||||
assert(g_params != nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <script/script.h>
|
||||
#include <test/util/json.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
@ -24,7 +25,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_parse)
|
|||
UniValue tests = read_json(std::string(json_tests::key_io_valid, json_tests::key_io_valid + sizeof(json_tests::key_io_valid)));
|
||||
CKey privkey;
|
||||
CTxDestination destination;
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
SelectParams(ChainType::MAIN);
|
||||
|
||||
for (unsigned int idx = 0; idx < tests.size(); idx++) {
|
||||
const UniValue& test = tests[idx];
|
||||
|
@ -37,7 +38,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_parse)
|
|||
const std::vector<std::byte> exp_payload{ParseHex<std::byte>(test[1].get_str())};
|
||||
const UniValue &metadata = test[2].get_obj();
|
||||
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
||||
SelectParams(find_value(metadata, "chain").get_str());
|
||||
SelectParams(ChainTypeFromString(find_value(metadata, "chain").get_str()).value());
|
||||
bool try_case_flip = find_value(metadata, "tryCaseFlip").isNull() ? false : find_value(metadata, "tryCaseFlip").get_bool();
|
||||
if (isPrivkey) {
|
||||
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
|
||||
|
@ -96,7 +97,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_gen)
|
|||
std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
|
||||
const UniValue &metadata = test[2].get_obj();
|
||||
bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
|
||||
SelectParams(find_value(metadata, "chain").get_str());
|
||||
SelectParams(ChainTypeFromString(find_value(metadata, "chain").get_str()).value());
|
||||
if (isPrivkey) {
|
||||
bool isCompressed = find_value(metadata, "isCompressed").get_bool();
|
||||
CKey key;
|
||||
|
@ -113,7 +114,7 @@ BOOST_AUTO_TEST_CASE(key_io_valid_gen)
|
|||
}
|
||||
}
|
||||
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
SelectParams(ChainType::MAIN);
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,7 +136,7 @@ BOOST_AUTO_TEST_CASE(key_io_invalid)
|
|||
std::string exp_base58string = test[0].get_str();
|
||||
|
||||
// must be invalid as public and as private key
|
||||
for (const auto& chain : { CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET, CBaseChainParams::REGTEST }) {
|
||||
for (const auto& chain : {ChainType::MAIN, ChainType::TESTNET, ChainType::SIGNET, ChainType::REGTEST}) {
|
||||
SelectParams(chain);
|
||||
destination = DecodeDestination(exp_base58string);
|
||||
BOOST_CHECK_MESSAGE(!IsValidDestination(destination), "IsValid pubkey in mainnet:" + strTest);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <pow.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
@ -15,7 +16,7 @@ BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup)
|
|||
/* Test calculation of next difficulty target with no constraints applying */
|
||||
BOOST_AUTO_TEST_CASE(get_next_work)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
int64_t nLastRetargetTime = 1261130161; // Block #30240
|
||||
CBlockIndex pindexLast;
|
||||
pindexLast.nHeight = 32255;
|
||||
|
@ -34,7 +35,7 @@ BOOST_AUTO_TEST_CASE(get_next_work)
|
|||
/* Test the constraint on the upper bound for next work */
|
||||
BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
int64_t nLastRetargetTime = 1231006505; // Block #0
|
||||
CBlockIndex pindexLast;
|
||||
pindexLast.nHeight = 2015;
|
||||
|
@ -48,7 +49,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
|
|||
/* Test the constraint on the lower bound for actual time taken */
|
||||
BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
int64_t nLastRetargetTime = 1279008237; // Block #66528
|
||||
CBlockIndex pindexLast;
|
||||
pindexLast.nHeight = 68543;
|
||||
|
@ -65,7 +66,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
|
|||
/* Test the constraint on the upper bound for actual time taken */
|
||||
BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
int64_t nLastRetargetTime = 1263163443; // NOTE: Not an actual block time
|
||||
CBlockIndex pindexLast;
|
||||
pindexLast.nHeight = 46367;
|
||||
|
@ -81,7 +82,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_negative_target)
|
||||
{
|
||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
||||
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||
uint256 hash;
|
||||
unsigned int nBits;
|
||||
nBits = UintToArith256(consensus.powLimit).GetCompact(true);
|
||||
|
@ -91,7 +92,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_negative_target)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_overflow_target)
|
||||
{
|
||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
||||
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||
uint256 hash;
|
||||
unsigned int nBits{~0x00800000U};
|
||||
hash.SetHex("0x1");
|
||||
|
@ -100,7 +101,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_overflow_target)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_too_easy_target)
|
||||
{
|
||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
||||
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||
uint256 hash;
|
||||
unsigned int nBits;
|
||||
arith_uint256 nBits_arith = UintToArith256(consensus.powLimit);
|
||||
|
@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_too_easy_target)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_biger_hash_than_target)
|
||||
{
|
||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
||||
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||
uint256 hash;
|
||||
unsigned int nBits;
|
||||
arith_uint256 hash_arith = UintToArith256(consensus.powLimit);
|
||||
|
@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_biger_hash_than_target)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_zero_target)
|
||||
{
|
||||
const auto consensus = CreateChainParams(*m_node.args, CBaseChainParams::MAIN)->GetConsensus();
|
||||
const auto consensus = CreateChainParams(*m_node.args, ChainType::MAIN)->GetConsensus();
|
||||
uint256 hash;
|
||||
unsigned int nBits;
|
||||
arith_uint256 hash_arith{0};
|
||||
|
@ -135,7 +136,7 @@ BOOST_AUTO_TEST_CASE(CheckProofOfWork_test_zero_target)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
std::vector<CBlockIndex> blocks(10000);
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
blocks[i].pprev = i ? &blocks[i - 1] : nullptr;
|
||||
|
@ -155,9 +156,9 @@ BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
|
|||
}
|
||||
}
|
||||
|
||||
void sanity_check_chainparams(const ArgsManager& args, std::string chainName)
|
||||
void sanity_check_chainparams(const ArgsManager& args, ChainType chain_type)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(args, chainName);
|
||||
const auto chainParams = CreateChainParams(args, chain_type);
|
||||
const auto consensus = chainParams->GetConsensus();
|
||||
|
||||
// hash genesis is correct
|
||||
|
@ -184,22 +185,22 @@ void sanity_check_chainparams(const ArgsManager& args, std::string chainName)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(ChainParams_MAIN_sanity)
|
||||
{
|
||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::MAIN);
|
||||
sanity_check_chainparams(*m_node.args, ChainType::MAIN);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ChainParams_REGTEST_sanity)
|
||||
{
|
||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::REGTEST);
|
||||
sanity_check_chainparams(*m_node.args, ChainType::REGTEST);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ChainParams_TESTNET_sanity)
|
||||
{
|
||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::TESTNET);
|
||||
sanity_check_chainparams(*m_node.args, ChainType::TESTNET);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ChainParams_SIGNET_sanity)
|
||||
{
|
||||
sanity_check_chainparams(*m_node.args, CBaseChainParams::SIGNET);
|
||||
sanity_check_chainparams(*m_node.args, ChainType::SIGNET);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/str.h>
|
||||
#include <util/fs.h>
|
||||
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <common/args.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
|
||||
|
@ -190,7 +190,7 @@ BOOST_FIXTURE_TEST_CASE(Merge, MergeTestingSetup)
|
|||
if (!out_file) throw std::system_error(errno, std::generic_category(), "fopen failed");
|
||||
}
|
||||
|
||||
const std::string& network = CBaseChainParams::MAIN;
|
||||
const std::string& network = ChainTypeToString(ChainType::MAIN);
|
||||
ForEachMergeSetup([&](const ActionList& arg_actions, const ActionList& conf_actions, bool force_set,
|
||||
bool ignore_default_section_config) {
|
||||
std::string desc;
|
||||
|
@ -225,7 +225,7 @@ BOOST_FIXTURE_TEST_CASE(Merge, MergeTestingSetup)
|
|||
}
|
||||
|
||||
desc += " || ";
|
||||
desc += GetSetting(settings, network, name, ignore_default_section_config, /*ignore_nonpersistent=*/false, /*get_chain_name=*/false).write();
|
||||
desc += GetSetting(settings, network, name, ignore_default_section_config, /*ignore_nonpersistent=*/false, /*get_chain_type=*/false).write();
|
||||
desc += " |";
|
||||
for (const auto& s : GetSettingsList(settings, network, name, ignore_default_section_config)) {
|
||||
desc += " ";
|
||||
|
|
|
@ -9,13 +9,14 @@
|
|||
#include <script/standard.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
struct Dersig100Setup : public TestChain100Setup {
|
||||
Dersig100Setup()
|
||||
: TestChain100Setup{CBaseChainParams::REGTEST, {"-testactivationheight=dersig@102"}} {}
|
||||
: TestChain100Setup{ChainType::REGTEST, {"-testactivationheight=dersig@102"}} {}
|
||||
};
|
||||
|
||||
bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <timedata.h>
|
||||
#include <txdb.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/string.h>
|
||||
#include <util/system.h>
|
||||
|
@ -98,7 +99,7 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
|
|||
return os;
|
||||
}
|
||||
|
||||
BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
||||
BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vector<const char*>& extra_args)
|
||||
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()},
|
||||
m_args{}
|
||||
{
|
||||
|
@ -132,7 +133,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
|
|||
throw std::runtime_error{error};
|
||||
}
|
||||
}
|
||||
SelectParams(chainName);
|
||||
SelectParams(chainType);
|
||||
SeedInsecureRand();
|
||||
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
|
||||
InitLogging(*m_node.args);
|
||||
|
@ -163,8 +164,8 @@ BasicTestingSetup::~BasicTestingSetup()
|
|||
gArgs.ClearArgs();
|
||||
}
|
||||
|
||||
ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
|
||||
: BasicTestingSetup(chainName, extra_args)
|
||||
ChainTestingSetup::ChainTestingSetup(const ChainType chainType, const std::vector<const char*>& extra_args)
|
||||
: BasicTestingSetup(chainType, extra_args)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
|
||||
|
@ -240,11 +241,11 @@ void ChainTestingSetup::LoadVerifyActivateChainstate()
|
|||
}
|
||||
|
||||
TestingSetup::TestingSetup(
|
||||
const std::string& chainName,
|
||||
const ChainType chainType,
|
||||
const std::vector<const char*>& extra_args,
|
||||
const bool coins_db_in_memory,
|
||||
const bool block_tree_db_in_memory)
|
||||
: ChainTestingSetup(chainName, extra_args)
|
||||
: ChainTestingSetup(chainType, extra_args)
|
||||
{
|
||||
m_coins_db_in_memory = coins_db_in_memory;
|
||||
m_block_tree_db_in_memory = block_tree_db_in_memory;
|
||||
|
@ -271,11 +272,11 @@ TestingSetup::TestingSetup(
|
|||
}
|
||||
|
||||
TestChain100Setup::TestChain100Setup(
|
||||
const std::string& chain_name,
|
||||
const ChainType chain_type,
|
||||
const std::vector<const char*>& extra_args,
|
||||
const bool coins_db_in_memory,
|
||||
const bool block_tree_db_in_memory)
|
||||
: TestingSetup{CBaseChainParams::REGTEST, extra_args, coins_db_in_memory, block_tree_db_in_memory}
|
||||
: TestingSetup{ChainType::REGTEST, extra_args, coins_db_in_memory, block_tree_db_in_memory}
|
||||
{
|
||||
SetMockTime(1598887952);
|
||||
constexpr std::array<unsigned char, 32> vchKey = {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#ifndef BITCOIN_TEST_UTIL_SETUP_COMMON_H
|
||||
#define BITCOIN_TEST_UTIL_SETUP_COMMON_H
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <common/args.h>
|
||||
#include <key.h>
|
||||
#include <node/caches.h>
|
||||
|
@ -14,6 +13,7 @@
|
|||
#include <pubkey.h>
|
||||
#include <random.h>
|
||||
#include <stdexcept>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/string.h>
|
||||
|
@ -80,7 +80,7 @@ static constexpr CAmount CENT{1000000};
|
|||
struct BasicTestingSetup {
|
||||
node::NodeContext m_node; // keep as first member to be destructed last
|
||||
|
||||
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
|
||||
explicit BasicTestingSetup(const ChainType chainType = ChainType::MAIN, const std::vector<const char*>& extra_args = {});
|
||||
~BasicTestingSetup();
|
||||
|
||||
const fs::path m_path_root;
|
||||
|
@ -96,7 +96,7 @@ struct ChainTestingSetup : public BasicTestingSetup {
|
|||
bool m_coins_db_in_memory{true};
|
||||
bool m_block_tree_db_in_memory{true};
|
||||
|
||||
explicit ChainTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
|
||||
explicit ChainTestingSetup(const ChainType chainType = ChainType::MAIN, const std::vector<const char*>& extra_args = {});
|
||||
~ChainTestingSetup();
|
||||
|
||||
// Supplies a chainstate, if one is needed
|
||||
|
@ -107,7 +107,7 @@ struct ChainTestingSetup : public BasicTestingSetup {
|
|||
*/
|
||||
struct TestingSetup : public ChainTestingSetup {
|
||||
explicit TestingSetup(
|
||||
const std::string& chainName = CBaseChainParams::MAIN,
|
||||
const ChainType chainType = ChainType::MAIN,
|
||||
const std::vector<const char*>& extra_args = {},
|
||||
const bool coins_db_in_memory = true,
|
||||
const bool block_tree_db_in_memory = true);
|
||||
|
@ -116,7 +116,7 @@ struct TestingSetup : public ChainTestingSetup {
|
|||
/** Identical to TestingSetup, but chain set to regtest */
|
||||
struct RegTestingSetup : public TestingSetup {
|
||||
RegTestingSetup()
|
||||
: TestingSetup{CBaseChainParams::REGTEST} {}
|
||||
: TestingSetup{ChainType::REGTEST} {}
|
||||
};
|
||||
|
||||
class CBlock;
|
||||
|
@ -128,7 +128,7 @@ class CScript;
|
|||
*/
|
||||
struct TestChain100Setup : public TestingSetup {
|
||||
TestChain100Setup(
|
||||
const std::string& chain_name = CBaseChainParams::REGTEST,
|
||||
const ChainType chain_type = ChainType::REGTEST,
|
||||
const std::vector<const char*>& extra_args = {},
|
||||
const bool coins_db_in_memory = true,
|
||||
const bool block_tree_db_in_memory = true);
|
||||
|
@ -206,7 +206,7 @@ struct TestChain100Setup : public TestingSetup {
|
|||
* be used in "hot loops", for example fuzzing or benchmarking.
|
||||
*/
|
||||
template <class T = const BasicTestingSetup>
|
||||
std::unique_ptr<T> MakeNoLogFileContext(const std::string& chain_name = CBaseChainParams::REGTEST, const std::vector<const char*>& extra_args = {})
|
||||
std::unique_ptr<T> MakeNoLogFileContext(const ChainType chain_type = ChainType::REGTEST, const std::vector<const char*>& extra_args = {})
|
||||
{
|
||||
const std::vector<const char*> arguments = Cat(
|
||||
{
|
||||
|
@ -215,7 +215,7 @@ std::unique_ptr<T> MakeNoLogFileContext(const std::string& chain_name = CBaseCha
|
|||
},
|
||||
extra_args);
|
||||
|
||||
return std::make_unique<T>(chain_name, arguments);
|
||||
return std::make_unique<T>(chain_type, arguments);
|
||||
}
|
||||
|
||||
CBlock getBlock13b8a();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <net.h>
|
||||
#include <signet.h>
|
||||
#include <uint256.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <test/util/setup_common.h>
|
||||
|
@ -41,7 +42,7 @@ static void TestBlockSubsidyHalvings(int nSubsidyHalvingInterval)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(block_subsidy_test)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
TestBlockSubsidyHalvings(chainParams->GetConsensus()); // As in main
|
||||
TestBlockSubsidyHalvings(150); // As in regtest
|
||||
TestBlockSubsidyHalvings(1000); // Just another interval
|
||||
|
@ -49,7 +50,7 @@ BOOST_AUTO_TEST_CASE(block_subsidy_test)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(subsidy_limit_test)
|
||||
{
|
||||
const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN);
|
||||
const auto chainParams = CreateChainParams(*m_node.args, ChainType::MAIN);
|
||||
CAmount nSum = 0;
|
||||
for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
|
||||
CAmount nSubsidy = GetBlockSubsidy(nHeight, chainParams->GetConsensus());
|
||||
|
@ -64,7 +65,7 @@ BOOST_AUTO_TEST_CASE(signet_parse_tests)
|
|||
{
|
||||
ArgsManager signet_argsman;
|
||||
signet_argsman.ForceSetArg("-signetchallenge", "51"); // set challenge to OP_TRUE
|
||||
const auto signet_params = CreateChainParams(signet_argsman, CBaseChainParams::SIGNET);
|
||||
const auto signet_params = CreateChainParams(signet_argsman, ChainType::SIGNET);
|
||||
CBlock block;
|
||||
BOOST_CHECK(signet_params->GetConsensus().signet_challenge == std::vector<uint8_t>{OP_TRUE});
|
||||
CScript challenge{OP_TRUE};
|
||||
|
@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(signet_parse_tests)
|
|||
//! Test retrieval of valid assumeutxo values.
|
||||
BOOST_AUTO_TEST_CASE(test_assumeutxo)
|
||||
{
|
||||
const auto params = CreateChainParams(*m_node.args, CBaseChainParams::REGTEST);
|
||||
const auto params = CreateChainParams(*m_node.args, ChainType::REGTEST);
|
||||
|
||||
// These heights don't have assumeutxo configurations associated, per the contents
|
||||
// of kernel/chainparams.cpp.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <consensus/params.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <versionbits.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
@ -418,8 +419,8 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
|
|||
|
||||
// check that any deployment on any chain can conceivably reach both
|
||||
// ACTIVE and FAILED states in roughly the way we expect
|
||||
for (const auto& chain_name : {CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::SIGNET, CBaseChainParams::REGTEST}) {
|
||||
const auto chainParams = CreateChainParams(*m_node.args, chain_name);
|
||||
for (const auto& chain_type: {ChainType::MAIN, ChainType::TESTNET, ChainType::SIGNET, ChainType::REGTEST}) {
|
||||
const auto chainParams = CreateChainParams(*m_node.args, chain_type);
|
||||
uint32_t chain_all_vbits{0};
|
||||
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i) {
|
||||
const auto dep = static_cast<Consensus::DeploymentPos>(i);
|
||||
|
@ -440,7 +441,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
|
|||
// deployment that's not always/never active
|
||||
ArgsManager args;
|
||||
args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999"); // January 1, 2008 - December 31, 2008
|
||||
const auto chainParams = CreateChainParams(args, CBaseChainParams::REGTEST);
|
||||
const auto chainParams = CreateChainParams(args, ChainType::REGTEST);
|
||||
check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY);
|
||||
}
|
||||
|
||||
|
@ -450,7 +451,7 @@ BOOST_AUTO_TEST_CASE(versionbits_computeblockversion)
|
|||
// live deployment
|
||||
ArgsManager args;
|
||||
args.ForceSetArg("-vbparams", "testdummy:1199145601:1230767999:403200"); // January 1, 2008 - December 31, 2008, min act height 403200
|
||||
const auto chainParams = CreateChainParams(args, CBaseChainParams::REGTEST);
|
||||
const auto chainParams = CreateChainParams(args, ChainType::REGTEST);
|
||||
check_computeblockversion(vbcache, chainParams->GetConsensus(), Consensus::DEPLOYMENT_TESTDUMMY);
|
||||
}
|
||||
}
|
||||
|
|
39
src/util/chaintype.cpp
Normal file
39
src/util/chaintype.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2023 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
std::string ChainTypeToString(ChainType chain)
|
||||
{
|
||||
switch (chain) {
|
||||
case ChainType::MAIN:
|
||||
return "main";
|
||||
case ChainType::TESTNET:
|
||||
return "test";
|
||||
case ChainType::SIGNET:
|
||||
return "signet";
|
||||
case ChainType::REGTEST:
|
||||
return "regtest";
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::optional<ChainType> ChainTypeFromString(std::string_view chain)
|
||||
{
|
||||
if (chain == "main") {
|
||||
return ChainType::MAIN;
|
||||
} else if (chain == "test") {
|
||||
return ChainType::TESTNET;
|
||||
} else if (chain == "signet") {
|
||||
return ChainType::SIGNET;
|
||||
} else if (chain == "regtest") {
|
||||
return ChainType::REGTEST;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
22
src/util/chaintype.h
Normal file
22
src/util/chaintype.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) 2023 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_CHAINTYPE_H
|
||||
#define BITCOIN_UTIL_CHAINTYPE_H
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
enum class ChainType {
|
||||
MAIN,
|
||||
TESTNET,
|
||||
SIGNET,
|
||||
REGTEST,
|
||||
};
|
||||
|
||||
std::string ChainTypeToString(ChainType chain);
|
||||
|
||||
std::optional<ChainType> ChainTypeFromString(std::string_view chain);
|
||||
|
||||
#endif // BITCOIN_UTIL_CHAINTYPE_H
|
|
@ -130,7 +130,7 @@ SettingsValue GetSetting(const Settings& settings,
|
|||
const std::string& name,
|
||||
bool ignore_default_section_config,
|
||||
bool ignore_nonpersistent,
|
||||
bool get_chain_name)
|
||||
bool get_chain_type)
|
||||
{
|
||||
SettingsValue result;
|
||||
bool done = false; // Done merging any more settings sources.
|
||||
|
@ -145,17 +145,17 @@ SettingsValue GetSetting(const Settings& settings,
|
|||
// assigned value instead of last. In general, later settings take
|
||||
// precedence over early settings, but for backwards compatibility in
|
||||
// the config file the precedence is reversed for all settings except
|
||||
// chain name settings.
|
||||
// chain type settings.
|
||||
const bool reverse_precedence =
|
||||
(source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) &&
|
||||
!get_chain_name;
|
||||
!get_chain_type;
|
||||
|
||||
// Weird behavior preserved for backwards compatibility: Negated
|
||||
// -regtest and -testnet arguments which you would expect to override
|
||||
// values set in the configuration file are currently accepted but
|
||||
// silently ignored. It would be better to apply these just like other
|
||||
// negated values, or at least warn they are ignored.
|
||||
const bool skip_negated_command_line = get_chain_name;
|
||||
const bool skip_negated_command_line = get_chain_type;
|
||||
|
||||
if (done) return;
|
||||
|
||||
|
|
|
@ -60,14 +60,14 @@ bool WriteSettings(const fs::path& path,
|
|||
//! command line). Only return settings in the
|
||||
//! read-only config and read-write settings
|
||||
//! files.
|
||||
//! @param get_chain_name - enable special backwards compatible behavior
|
||||
//! for GetChainName
|
||||
//! @param get_chain_type - enable special backwards compatible behavior
|
||||
//! for GetChainType
|
||||
SettingsValue GetSetting(const Settings& settings,
|
||||
const std::string& section,
|
||||
const std::string& name,
|
||||
bool ignore_default_section_config,
|
||||
bool ignore_nonpersistent,
|
||||
bool get_chain_name);
|
||||
bool get_chain_type);
|
||||
|
||||
//! Get combined setting value similar to GetSetting(), except if setting was
|
||||
//! specified multiple times, return a list of all the values specified.
|
||||
|
|
|
@ -45,7 +45,7 @@ ExternalSigner ExternalSignerScriptPubKeyMan::GetExternalSigner() {
|
|||
const std::string command = gArgs.GetArg("-signer", "");
|
||||
if (command == "") throw std::runtime_error(std::string(__func__) + ": restart bitcoind with -signer=<cmd>");
|
||||
std::vector<ExternalSigner> signers;
|
||||
ExternalSigner::Enumerate(command, signers, Params().NetworkIDString());
|
||||
ExternalSigner::Enumerate(command, signers, Params().GetChainTypeString());
|
||||
if (signers.empty()) throw std::runtime_error(std::string(__func__) + ": No external signers found");
|
||||
// TODO: add fingerprint argument instead of failing in case of multiple signers.
|
||||
if (signers.size() > 1) throw std::runtime_error(std::string(__func__) + ": More than one external signer found. Please connect only one at a time.");
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <common/args.h>
|
||||
#include <univalue.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <util/fs.h>
|
||||
|
||||
|
@ -13,7 +14,7 @@
|
|||
#include <wallet/test/init_test_fixture.h>
|
||||
|
||||
namespace wallet {
|
||||
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
|
||||
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const ChainType chainType) : BasicTestingSetup(chainType)
|
||||
{
|
||||
m_wallet_loader = MakeWalletLoader(*m_node.chain, m_args);
|
||||
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
#include <interfaces/wallet.h>
|
||||
#include <node/context.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
struct InitWalletDirTestingSetup: public BasicTestingSetup {
|
||||
explicit InitWalletDirTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
||||
explicit InitWalletDirTestingSetup(const ChainType chain_type = ChainType::MAIN);
|
||||
~InitWalletDirTestingSetup();
|
||||
void SetWalletDir(const fs::path& walletdir_path);
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
#include <wallet/test/wallet_test_fixture.h>
|
||||
|
||||
#include <scheduler.h>
|
||||
#include <util/chaintype.h>
|
||||
|
||||
namespace wallet {
|
||||
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
|
||||
: TestingSetup(chainName),
|
||||
WalletTestingSetup::WalletTestingSetup(const ChainType chainType)
|
||||
: TestingSetup(chainType),
|
||||
m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))},
|
||||
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <interfaces/chain.h>
|
||||
#include <interfaces/wallet.h>
|
||||
#include <node/context.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/check.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
|
@ -19,7 +20,7 @@ namespace wallet {
|
|||
/** Testing setup and teardown for wallet.
|
||||
*/
|
||||
struct WalletTestingSetup : public TestingSetup {
|
||||
explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
||||
explicit WalletTestingSetup(const ChainType chainType = ChainType::MAIN);
|
||||
~WalletTestingSetup();
|
||||
|
||||
std::unique_ptr<interfaces::WalletLoader> m_wallet_loader;
|
||||
|
|
Loading…
Add table
Reference in a new issue