diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -206,7 +206,6 @@ wallet/finaltx.h \ wallet/rpcdump.h \ wallet/fees.h \ - wallet/init.h \ wallet/rpcwallet.h \ wallet/wallet.h \ wallet/walletdb.h \ diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -19,9 +19,6 @@ #include "rpc/server.h" #include "util.h" #include "utilstrencodings.h" -#if ENABLE_WALLET -#include "wallet/init.h" -#endif #include "walletinitinterface.h" #include @@ -70,12 +67,6 @@ bool fRet = false; -#if ENABLE_WALLET - g_wallet_init_interface.reset(new WalletInit); -#else - g_wallet_init_interface.reset(new DummyWalletInit); -#endif - // // Parameters // diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -75,7 +75,24 @@ std::unique_ptr g_connman; std::unique_ptr peerLogic; -std::unique_ptr g_wallet_init_interface; + +#if !(ENABLE_WALLET) +class DummyWalletInit : public WalletInitInterface { +public: + std::string GetHelpString(bool showDebug) override { return std::string{}; } + bool ParameterInteraction() override { return true; } + void RegisterRPC(CRPCTable &) override {} + bool Verify(const CChainParams &chainParams) override { return true; } + bool Open(const CChainParams &chainParams) override { return true; } + void Start(CScheduler &scheduler) override {} + void Flush() override {} + void Stop() override {} + void Close() override {} +}; + +std::unique_ptr + g_wallet_init_interface(new DummyWalletInit); +#endif #if ENABLE_ZMQ static CZMQNotificationInterface *pzmqNotificationInterface = nullptr; diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -35,7 +35,6 @@ #include "warnings.h" #ifdef ENABLE_WALLET -#include "wallet/init.h" #include "wallet/wallet.h" #endif #include "walletinitinterface.h" @@ -756,11 +755,6 @@ // bitcoincash: links repeatedly have their payment requests routed to this // process: app.createPaymentServer(); - - // Hook up the wallet init interface - g_wallet_init_interface.reset(new WalletInit); -#else - g_wallet_init_interface.reset(new DummyWalletInit); #endif /// 9. Main GUI initialization diff --git a/src/wallet/init.h b/src/wallet/init.h deleted file mode 100644 --- a/src/wallet/init.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2017 The Bitcoin Core developers -// Copyright (c) 2018 The Bitcoin developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_WALLET_INIT_H -#define BITCOIN_WALLET_INIT_H - -#include "chainparams.h" -#include "walletinitinterface.h" - -#include - -class CRPCTable; -class CScheduler; - -class WalletInit : public WalletInitInterface { -public: - /** - * Return the wallets help message. - */ - std::string GetHelpString(bool showDebug) override; - - /** - * Wallets parameter interaction - */ - bool ParameterInteraction() override; - - /** - * Register wallet RPCs. - */ - void RegisterRPC(CRPCTable &tableRPC) override; - - /** - * Responsible for reading and validating the -wallet arguments and - * verifying the wallet database. - * This function will perform salvage on the wallet if requested, as long as - * only one wallet is being loaded (WalletParameterInteraction forbids - * -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet). - */ - bool Verify(const CChainParams &chainParams) override; - - /** - * Load wallet databases. - */ - bool Open(const CChainParams &chainParams) override; - - /** - * Complete startup of wallets. - */ - void Start(CScheduler &scheduler) override; - - /** - * Flush all wallets in preparation for shutdown. - */ - void Flush() override; - - /** - * Stop all wallets. Wallets will be flushed first. - */ - void Stop() override; - - /** - * Close all wallets. - */ - void Close() override; -}; - -#endif // BITCOIN_WALLET_INIT_H diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -4,8 +4,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "wallet/init.h" - #include "config.h" #include "net.h" #include "util.h" @@ -13,6 +11,43 @@ #include "validation.h" #include "wallet/rpcwallet.h" #include "wallet/wallet.h" +#include "walletinitinterface.h" + +class WalletInit : public WalletInitInterface { +public: + //! Return the wallets help message. + std::string GetHelpString(bool showDebug) override; + + //! Wallets parameter interaction + bool ParameterInteraction() override; + + //! Register wallet RPCs. + void RegisterRPC(CRPCTable &tableRPC) override; + + //! Responsible for reading and validating the -wallet arguments and + //! verifying the wallet database. + // This function will perform salvage on the wallet if requested, as long + // as only one wallet is being loaded (WalletParameterInteraction forbids + // -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet). + bool Verify(const CChainParams &chainParams) override; + + //! Load wallet databases. + bool Open(const CChainParams &chainParams) override; + + //! Complete startup of wallets. + void Start(CScheduler &scheduler) override; + + //! Flush all wallets in preparation for shutdown. + void Flush() override; + + //! Stop all wallets. Wallets will be flushed first. + void Stop() override; + + //! Close all wallets. + void Close() override; +}; + +std::unique_ptr g_wallet_init_interface(new WalletInit); std::string WalletInit::GetHelpString(bool showDebug) { std::string strUsage = HelpMessageGroup(_("Wallet options:")); diff --git a/src/walletinitinterface.h b/src/walletinitinterface.h --- a/src/walletinitinterface.h +++ b/src/walletinitinterface.h @@ -36,17 +36,4 @@ virtual ~WalletInitInterface() {} }; -class DummyWalletInit : public WalletInitInterface { -public: - std::string GetHelpString(bool showDebug) override { return std::string{}; } - bool ParameterInteraction() override { return true; } - void RegisterRPC(CRPCTable &) override {} - bool Verify(const CChainParams &chainParams) override { return true; } - bool Open(const CChainParams &chainParams) override { return true; } - void Start(CScheduler &scheduler) override {} - void Flush() override {} - void Stop() override {} - void Close() override {} -}; - #endif // WALLETINITINTERFACE_H