From 84ce18ca9339901f65d77a5821eb65f771316558 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 19 Jun 2014 15:10:04 +0200 Subject: [PATCH] Remove unnecessary dependencies for bitcoin-cli This commit removes all the unnecessary dependencies (key, core, netbase, sync, ...) from bitcoin-cli. To do this it shards the chain parameters into BaseParams, which contains just the RPC port and data directory (as used by utils and bitcoin-cli) and Params, with the rest. --- src/Makefile.am | 58 +++++++++++++------ src/Makefile.qt.include | 4 +- src/Makefile.qttest.include | 2 +- src/Makefile.test.include | 2 +- src/bitcoin-cli.cpp | 9 ++- src/chainparams.cpp | 36 ++++-------- src/chainparams.h | 19 ++---- src/chainparamsbase.cpp | 93 ++++++++++++++++++++++++++++++ src/chainparamsbase.h | 52 +++++++++++++++++ src/checkpoints.cpp | 4 +- src/qt/bitcoin.cpp | 2 +- src/qt/paymentserver.cpp | 8 +-- src/qt/test/paymentservertests.cpp | 1 + src/rpcmining.cpp | 2 +- src/rpcmisc.cpp | 2 +- src/rpcserver.cpp | 2 +- src/test/base58_tests.cpp | 12 ++-- src/test/test_bitcoin.cpp | 1 + src/util.cpp | 12 ++-- 19 files changed, 232 insertions(+), 89 deletions(-) create mode 100644 src/chainparamsbase.cpp create mode 100644 src/chainparamsbase.h diff --git a/src/Makefile.am b/src/Makefile.am index cd54b0496..2d2ae2a4c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,10 +20,19 @@ endif BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) +LIBBITCOIN_SERVER=libbitcoin_server.a +LIBBITCOIN_WALLET=libbitcoin_wallet.a +LIBBITCOIN_COMMON=libbitcoin_common.a +LIBBITCOIN_CLI=libbitcoin_cli.a +LIBBITCOIN_UTIL=libbitcoin_util.a +LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a +LIBBITCOINQT=qt/libbitcoinqt.a + noinst_LIBRARIES = \ libbitcoin_server.a \ libbitcoin_common.a \ libbitcoin_cli.a \ + libbitcoin_util.a \ crypto/libbitcoin_crypto.a if ENABLE_WALLET BITCOIN_INCLUDES += $(BDB_CPPFLAGS) @@ -50,6 +59,7 @@ BITCOIN_CORE_H = \ base58.h \ bloom.h \ chainparams.h \ + chainparamsbase.h \ checkpoints.h \ checkqueue.h \ clientversion.h \ @@ -107,8 +117,9 @@ obj/build.h: FORCE @$(MKDIR_P) $(builddir)/obj @$(top_srcdir)/share/genbuild.sh $(abs_top_builddir)/src/obj/build.h \ $(abs_top_srcdir) -libbitcoin_common_a-version.$(OBJEXT): obj/build.h +libbitcoin_util_a-version.$(OBJEXT): obj/build.h +# server: shared between bitcoind and bitcoin-qt libbitcoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES) libbitcoin_server_a_SOURCES = \ addrman.cpp \ @@ -136,6 +147,8 @@ libbitcoin_server_a_SOURCES = \ $(JSON_H) \ $(BITCOIN_CORE_H) +# wallet: shared between bitcoind and bitcoin-qt, but only linked +# when wallet enabled libbitcoin_wallet_a_CPPFLAGS = $(BITCOIN_INCLUDES) libbitcoin_wallet_a_SOURCES = \ db.cpp \ @@ -146,6 +159,7 @@ libbitcoin_wallet_a_SOURCES = \ walletdb.cpp \ $(BITCOIN_CORE_H) +# crypto primitives library crypto_libbitcoin_crypto_a_CPPFLAGS = $(BITCOIN_CONFIG_INCLUDES) crypto_libbitcoin_crypto_a_SOURCES = \ crypto/sha1.cpp \ @@ -156,6 +170,7 @@ crypto_libbitcoin_crypto_a_SOURCES = \ crypto/sha1.h \ crypto/ripemd160.h +# common: shared between bitcoind, and bitcoin-qt and non-server tools libbitcoin_common_a_CPPFLAGS = $(BITCOIN_INCLUDES) libbitcoin_common_a_SOURCES = \ base58.cpp \ @@ -166,8 +181,16 @@ libbitcoin_common_a_SOURCES = \ key.cpp \ netbase.cpp \ protocol.cpp \ - rpcprotocol.cpp \ script.cpp \ + $(BITCOIN_CORE_H) + +# util: shared between all executables. +# This library *must* be included to make sure that the glibc +# backward-compatibility objects and their sanity checks are linked. +libbitcoin_util_a_CPPFLAGS = $(BITCOIN_INCLUDES) +libbitcoin_util_a_SOURCES = \ + chainparamsbase.cpp \ + rpcprotocol.cpp \ sync.cpp \ util.cpp \ version.cpp \ @@ -176,22 +199,24 @@ libbitcoin_common_a_SOURCES = \ $(BITCOIN_CORE_H) if GLIBC_BACK_COMPAT -libbitcoin_common_a_SOURCES += compat/glibc_compat.cpp -libbitcoin_common_a_SOURCES += compat/glibcxx_compat.cpp +libbitcoin_util_a_SOURCES += compat/glibc_compat.cpp +libbitcoin_util_a_SOURCES += compat/glibcxx_compat.cpp endif +# cli: shared between bitcoin-cli and bitcoin-qt libbitcoin_cli_a_SOURCES = \ rpcclient.cpp \ $(BITCOIN_CORE_H) -nodist_libbitcoin_common_a_SOURCES = $(srcdir)/obj/build.h +nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h # # bitcoind binary # bitcoind_LDADD = \ - libbitcoin_server.a \ - libbitcoin_common.a \ - crypto/libbitcoin_crypto.a \ + $(LIBBITCOIN_SERVER) \ + $(LIBBITCOIN_COMMON) \ + $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CRYPTO) \ $(LIBLEVELDB) \ $(LIBMEMENV) if ENABLE_WALLET @@ -209,11 +234,13 @@ bitcoind_CPPFLAGS = $(BITCOIN_INCLUDES) # bitcoin-cli binary # bitcoin_cli_LDADD = \ - libbitcoin_cli.a \ - libbitcoin_common.a \ - crypto/libbitcoin_crypto.a \ + $(LIBBITCOIN_CLI) \ + $(LIBBITCOIN_COMMON) \ + $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CRYPTO) \ $(BOOST_LIBS) -bitcoin_cli_SOURCES = bitcoin-cli.cpp +bitcoin_cli_SOURCES = \ + bitcoin-cli.cpp bitcoin_cli_CPPFLAGS = $(BITCOIN_INCLUDES) # @@ -244,13 +271,6 @@ clean-local: @test -f $(PROTOC) $(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $( @@ -60,12 +60,11 @@ static bool AppInitRPC(int argc, char* argv[]) fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; } - // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) - if (!SelectParamsFromCommandLine()) { + // Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) + if (!SelectBaseParamsFromCommandLine()) { fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n"); return false; } - if (argc<2 || mapArgs.count("-?") || mapArgs.count("-help") || mapArgs.count("-version")) { std::string strUsage = _("Bitcoin Core RPC client version") + " " + FormatFullVersion() + "\n"; @@ -104,7 +103,7 @@ Object CallRPC(const string& strMethod, const Array& params) bool fWait = GetBoolArg("-rpcwait", false); // -rpcwait means try until server has started do { - bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(Params().RPCPort()))); + bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(BaseParams().RPCPort()))); if (fConnected) break; if (fWait) MilliSleep(1000); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index eb56af750..63067a153 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -99,7 +99,7 @@ unsigned int pnSeed[] = class CMainParams : public CChainParams { public: CMainParams() { - networkID = CChainParams::MAIN; + networkID = CBaseChainParams::MAIN; strNetworkID = "main"; // The message start string is designed to be unlikely to occur in normal data. // The characters are rarely used upper ASCII, not valid as UTF-8, and produce @@ -110,7 +110,6 @@ public: pchMessageStart[3] = 0xd9; vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284"); nDefaultPort = 8333; - nRPCPort = 8332; bnProofOfWorkLimit = ~uint256(0) >> 32; nSubsidyHalvingInterval = 210000; nEnforceBlockUpgradeMajority = 750; @@ -191,7 +190,7 @@ static CMainParams mainParams; class CTestNetParams : public CMainParams { public: CTestNetParams() { - networkID = CChainParams::TESTNET; + networkID = CBaseChainParams::TESTNET; strNetworkID = "test"; // The message start string is designed to be unlikely to occur in normal data. // The characters are rarely used upper ASCII, not valid as UTF-8, and produce @@ -202,14 +201,12 @@ public: pchMessageStart[3] = 0x07; vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a"); nDefaultPort = 18333; - nRPCPort = 18332; nEnforceBlockUpgradeMajority = 51; nRejectBlockOutdatedMajority = 75; nToCheckBlockUpgradeMajority = 100; nMinerThreads = 0; nTargetTimespan = 14 * 24 * 60 * 60; // two weeks nTargetSpacing = 10 * 60; - strDataDir = "testnet3"; // Modify the testnet genesis block so the timestamp is valid for a later start. genesis.nTime = 1296688602; @@ -245,7 +242,7 @@ static CTestNetParams testNetParams; class CRegTestParams : public CTestNetParams { public: CRegTestParams() { - networkID = CChainParams::REGTEST; + networkID = CBaseChainParams::REGTEST; strNetworkID = "regtest"; pchMessageStart[0] = 0xfa; pchMessageStart[1] = 0xbf; @@ -264,7 +261,6 @@ public: genesis.nNonce = 2; hashGenesisBlock = genesis.GetHash(); nDefaultPort = 18444; - strDataDir = "regtest"; assert(hashGenesisBlock == uint256("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")); vSeeds.clear(); // Regtest mode doesn't have any DNS seeds. @@ -279,21 +275,23 @@ public: }; static CRegTestParams regTestParams; -static CChainParams *pCurrentParams = &mainParams; +static CChainParams *pCurrentParams = 0; const CChainParams &Params() { + assert(pCurrentParams); return *pCurrentParams; } -void SelectParams(CChainParams::Network network) { +void SelectParams(CBaseChainParams::Network network) { + SelectBaseParams(network); switch (network) { - case CChainParams::MAIN: + case CBaseChainParams::MAIN: pCurrentParams = &mainParams; break; - case CChainParams::TESTNET: + case CBaseChainParams::TESTNET: pCurrentParams = &testNetParams; break; - case CChainParams::REGTEST: + case CBaseChainParams::REGTEST: pCurrentParams = ®TestParams; break; default: @@ -303,19 +301,9 @@ void SelectParams(CChainParams::Network network) { } bool SelectParamsFromCommandLine() { - bool fRegTest = GetBoolArg("-regtest", false); - bool fTestNet = GetBoolArg("-testnet", false); - - if (fTestNet && fRegTest) { + if (!SelectBaseParamsFromCommandLine()) return false; - } - if (fRegTest) { - SelectParams(CChainParams::REGTEST); - } else if (fTestNet) { - SelectParams(CChainParams::TESTNET); - } else { - SelectParams(CChainParams::MAIN); - } + SelectParams(BaseParams().NetworkID()); return true; } diff --git a/src/chainparams.h b/src/chainparams.h index e9774bbfa..446256ba8 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -7,6 +7,7 @@ #define BITCOIN_CHAIN_PARAMS_H #include "core.h" +#include "chainparamsbase.h" #include "protocol.h" #include "uint256.h" @@ -29,14 +30,6 @@ struct CDNSSeedData { class CChainParams { public: - enum Network { - MAIN, - TESTNET, - REGTEST, - - MAX_NETWORK_TYPES - }; - enum Base58Type { PUBKEY_ADDRESS, SCRIPT_ADDRESS, @@ -73,17 +66,15 @@ public: int64_t TargetTimespan() const { return nTargetTimespan; } int64_t TargetSpacing() const { return nTargetSpacing; } int64_t Interval() const { return nTargetTimespan / nTargetSpacing; } - const std::string& DataDir() const { return strDataDir; } /* Make miner stop after a block is found. In RPC, don't return * until nGenProcLimit blocks are generated */ bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } - Network NetworkID() const { return networkID; } + CBaseChainParams::Network NetworkID() const { return networkID; } /* Return the BIP70 network string (main, test or regtest) */ std::string NetworkIDString() const { return strNetworkID; } const std::vector& DNSSeeds() const { return vSeeds; } const std::vector& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } const std::vector& FixedSeeds() const { return vFixedSeeds; } - int RPCPort() const { return nRPCPort; } protected: CChainParams() {} @@ -92,7 +83,6 @@ protected: // Raw pub key bytes for the broadcast alert signing key. std::vector vAlertPubKey; int nDefaultPort; - int nRPCPort; uint256 bnProofOfWorkLimit; int nSubsidyHalvingInterval; int nEnforceBlockUpgradeMajority; @@ -100,11 +90,10 @@ protected: int nToCheckBlockUpgradeMajority; int64_t nTargetTimespan; int64_t nTargetSpacing; - std::string strDataDir; int nMinerThreads; std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; - Network networkID; + CBaseChainParams::Network networkID; std::string strNetworkID; CBlock genesis; std::vector vFixedSeeds; @@ -123,7 +112,7 @@ protected: const CChainParams &Params(); /** Sets the params returned by Params() to those for the given network. */ -void SelectParams(CChainParams::Network network); +void SelectParams(CBaseChainParams::Network network); /** * Looks for -regtest or -testnet and then calls SelectParams as appropriate. diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp new file mode 100644 index 000000000..19a9e72cc --- /dev/null +++ b/src/chainparamsbase.cpp @@ -0,0 +1,93 @@ +// Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "chainparamsbase.h" + +#include "assert.h" +#include "util.h" + +#include + +using namespace boost::assign; + +// +// Main network +// + +class CBaseMainParams : public CBaseChainParams { +public: + CBaseMainParams() { + networkID = CBaseChainParams::MAIN; + nRPCPort = 8332; + } +}; +static CBaseMainParams mainParams; + +// +// Testnet (v3) +// +class CBaseTestNetParams : public CBaseMainParams { +public: + CBaseTestNetParams() { + networkID = CBaseChainParams::TESTNET; + nRPCPort = 18332; + strDataDir = "testnet3"; + } +}; +static CBaseTestNetParams testNetParams; + +// +// Regression test +// +class CBaseRegTestParams : public CBaseTestNetParams { +public: + CBaseRegTestParams() { + networkID = CBaseChainParams::REGTEST; + strDataDir = "regtest"; + } +}; +static CBaseRegTestParams regTestParams; + +static CBaseChainParams *pCurrentBaseParams = 0; + +const CBaseChainParams &BaseParams() { + assert(pCurrentBaseParams); + return *pCurrentBaseParams; +} + +void SelectBaseParams(CBaseChainParams::Network network) { + switch (network) { + case CBaseChainParams::MAIN: + pCurrentBaseParams = &mainParams; + break; + case CBaseChainParams::TESTNET: + pCurrentBaseParams = &testNetParams; + break; + case CBaseChainParams::REGTEST: + pCurrentBaseParams = ®TestParams; + break; + default: + assert(false && "Unimplemented network"); + return; + } +} + +bool SelectBaseParamsFromCommandLine() { + bool fRegTest = GetBoolArg("-regtest", false); + bool fTestNet = GetBoolArg("-testnet", false); + + if (fTestNet && fRegTest) { + return false; + } + + if (fRegTest) { + SelectBaseParams(CBaseChainParams::REGTEST); + } else if (fTestNet) { + SelectBaseParams(CBaseChainParams::TESTNET); + } else { + SelectBaseParams(CBaseChainParams::MAIN); + } + return true; +} diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h new file mode 100644 index 000000000..4a3b26890 --- /dev/null +++ b/src/chainparamsbase.h @@ -0,0 +1,52 @@ +// Copyright (c) 2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CHAIN_PARAMS_BASE_H +#define BITCOIN_CHAIN_PARAMS_BASE_H + +#include +#include + +/** + * CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) + * of a given instance of the Bitcoin system. + */ +class CBaseChainParams +{ +public: + enum Network { + MAIN, + TESTNET, + REGTEST, + + MAX_NETWORK_TYPES + }; + + const std::string& DataDir() const { return strDataDir; } + int RPCPort() const { return nRPCPort; } + Network NetworkID() const { return networkID; } +protected: + CBaseChainParams() {} + + int nRPCPort; + std::string strDataDir; + Network networkID; +}; + +/** + * Return the currently selected parameters. This won't change after app startup + * outside of the unit tests. + */ +const CBaseChainParams &BaseParams(); + +/** Sets the params returned by Params() to those for the given network. */ +void SelectBaseParams(CBaseChainParams::Network network); + +/** + * Looks for -regtest or -testnet and then calls SelectParams as appropriate. + * Returns false if an invalid combination is given. + */ +bool SelectBaseParamsFromCommandLine(); + +#endif diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 926949e06..75ac41891 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -83,9 +83,9 @@ namespace Checkpoints }; const CCheckpointData &Checkpoints() { - if (Params().NetworkID() == CChainParams::TESTNET) + if (Params().NetworkID() == CBaseChainParams::TESTNET) return dataTestnet; - else if (Params().NetworkID() == CChainParams::MAIN) + else if (Params().NetworkID() == CBaseChainParams::MAIN) return data; else return dataRegtest; diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 76dddb103..89305e9f3 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -546,7 +546,7 @@ int main(int argc, char *argv[]) if (!PaymentServer::ipcParseCommandLine(argc, argv)) exit(0); #endif - bool isaTestNet = Params().NetworkID() != CChainParams::MAIN; + bool isaTestNet = Params().NetworkID() != CBaseChainParams::MAIN; // Allow for separate UI settings for testnets if (isaTestNet) QApplication::setApplicationName(QAPP_APP_NAME_TESTNET); diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 49923a1af..fbb11617f 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -199,10 +199,10 @@ bool PaymentServer::ipcParseCommandLine(int argc, char* argv[]) { CBitcoinAddress address(r.address.toStdString()); - SelectParams(CChainParams::MAIN); + SelectParams(CBaseChainParams::MAIN); if (!address.IsValid()) { - SelectParams(CChainParams::TESTNET); + SelectParams(CBaseChainParams::TESTNET); } } } @@ -214,9 +214,9 @@ bool PaymentServer::ipcParseCommandLine(int argc, char* argv[]) if (readPaymentRequest(arg, request)) { if (request.getDetails().network() == "main") - SelectParams(CChainParams::MAIN); + SelectParams(CBaseChainParams::MAIN); else - SelectParams(CChainParams::TESTNET); + SelectParams(CBaseChainParams::TESTNET); } } else diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp index 7dee7a9cd..e92a7d2b1 100644 --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -56,6 +56,7 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vectorGetOldestKeyPoolTime())); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 93da81e42..c5d09cf57 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -600,7 +600,7 @@ void StartRPCThreads() std::vector vEndpoints; bool bBindAny = false; - int defaultPort = GetArg("-rpcport", Params().RPCPort()); + int defaultPort = GetArg("-rpcport", BaseParams().RPCPort()); if (!mapArgs.count("-rpcallowip")) // Default to loopback if not allowing external IPs { vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v6::loopback(), defaultPort)); diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index b81a19cfd..0ac3e9a36 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -142,9 +142,9 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_parse) bool isPrivkey = find_value(metadata, "isPrivkey").get_bool(); bool isTestnet = find_value(metadata, "isTestnet").get_bool(); if (isTestnet) - SelectParams(CChainParams::TESTNET); + SelectParams(CBaseChainParams::TESTNET); else - SelectParams(CChainParams::MAIN); + SelectParams(CBaseChainParams::MAIN); if(isPrivkey) { bool isCompressed = find_value(metadata, "isCompressed").get_bool(); @@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_parse) BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid pubkey as privkey:" + strTest); } } - SelectParams(CChainParams::MAIN); + SelectParams(CBaseChainParams::MAIN); } // Goal: check that generated keys match test vectors @@ -198,9 +198,9 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen) bool isPrivkey = find_value(metadata, "isPrivkey").get_bool(); bool isTestnet = find_value(metadata, "isTestnet").get_bool(); if (isTestnet) - SelectParams(CChainParams::TESTNET); + SelectParams(CBaseChainParams::TESTNET); else - SelectParams(CChainParams::MAIN); + SelectParams(CBaseChainParams::MAIN); if(isPrivkey) { bool isCompressed = find_value(metadata, "isCompressed").get_bool(); @@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(base58_keys_valid_gen) CTxDestination nodest = CNoDestination(); BOOST_CHECK(!dummyAddr.Set(nodest)); - SelectParams(CChainParams::MAIN); + SelectParams(CBaseChainParams::MAIN); } // Goal: check that base58 parsing code is robust against a variety of corrupted data diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 2d993e24d..8cae0a4c3 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -31,6 +31,7 @@ struct TestingSetup { TestingSetup() { fPrintToDebugLog = false; // don't want to write to debug.log file + SelectParams(CBaseChainParams::MAIN); noui_connect(); #ifdef ENABLE_WALLET bitdb.MakeMock(); diff --git a/src/util.cpp b/src/util.cpp index a19c015da..7a0e2cc80 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -5,7 +5,7 @@ #include "util.h" -#include "chainparams.h" +#include "chainparamsbase.h" #include "sync.h" #include "ui_interface.h" #include "uint256.h" @@ -918,7 +918,7 @@ boost::filesystem::path GetDefaultDataDir() #endif } -static boost::filesystem::path pathCached[CChainParams::MAX_NETWORK_TYPES+1]; +static boost::filesystem::path pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1]; static CCriticalSection csPathCached; const boost::filesystem::path &GetDataDir(bool fNetSpecific) @@ -927,8 +927,8 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) LOCK(csPathCached); - int nNet = CChainParams::MAX_NETWORK_TYPES; - if (fNetSpecific) nNet = Params().NetworkID(); + int nNet = CBaseChainParams::MAX_NETWORK_TYPES; + if (fNetSpecific) nNet = BaseParams().NetworkID(); fs::path &path = pathCached[nNet]; @@ -947,7 +947,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) path = GetDefaultDataDir(); } if (fNetSpecific) - path /= Params().DataDir(); + path /= BaseParams().DataDir(); fs::create_directories(path); @@ -956,7 +956,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) void ClearDatadirCache() { - std::fill(&pathCached[0], &pathCached[CChainParams::MAX_NETWORK_TYPES+1], + std::fill(&pathCached[0], &pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1], boost::filesystem::path()); }