diff --git a/src/Makefile.am b/src/Makefile.am index c30ffe2b78..4cce3dcf90 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -407,6 +407,10 @@ libdash_server_a_SOURCES = \ versionbits.cpp \ $(BITCOIN_CORE_H) +if !ENABLE_WALLET +libdash_server_a_SOURCES += dummywallet.cpp +endif + if ENABLE_ZMQ libdash_zmq_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(ZMQ_CFLAGS) libdash_zmq_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) diff --git a/src/dummywallet.cpp b/src/dummywallet.cpp new file mode 100644 index 0000000000..ee6a0b6de3 --- /dev/null +++ b/src/dummywallet.cpp @@ -0,0 +1,47 @@ +// Copyright (c) 2018 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 +#include +#include + +#include + +class DummyWalletInit : public WalletInitInterface { +public: + + bool HasWalletSupport() const override {return false;} + void AddWalletOptions() const override; + bool ParameterInteraction() const override {return true;} + void RegisterRPC(CRPCTable &) const override {} + bool Verify() const override {return true;} + bool Open() const override {LogPrintf("No wallet support compiled in!\n"); return true;} + void Start(CScheduler& scheduler) const override {} + void Flush() const override {} + void Stop() const override {} + void Close() const override {} + + // Dash Specific WalletInitInterface InitCoinJoinSettings + void AutoLockMasternodeCollaterals() const override {} + void InitCoinJoinSettings() const override {} + void InitKeePass() const override {} + bool InitAutoBackup() const override {return true;} +}; + +void DummyWalletInit::AddWalletOptions() const +{ + std::vector opts = {"-createwalletbackups=", "-disablewallet", "-instantsendnotify=", + "-keypool=", "-rescan=", "-salvagewallet", "-spendzeroconfchange", "-upgradewallet", + "-wallet=", "-walletbackupsdir=", "-walletbroadcast", "-walletdir=", + "-walletnotify=", "-zapwallettxes=", "-discardfee=", "-fallbackfee=", + "-mintxfee=", "-paytxfee=", "-txconfirmtarget=", "-hdseed=", "-mnemonic=", + "-mnemonicpassphrase=", "-usehd", "-keepass", "-keepassid=", "-keepasskey=", + "-keepassname=", "-keepassport=", "-enablecoinjoin", "-coinjoinamount=", + "-coinjoinautostart", "-coinjoindenomsgoal=", "-coinjoindenomshardcap=", "-coinjoinmultisession", + "-coinjoinrounds=", "-coinjoinsessions=", "-dblogsize=", "-flushwallet", "-privdb", + "-walletrejectlongchains"}; + gArgs.AddHiddenArgs(opts); +} + +const WalletInitInterface& g_wallet_init_interface = DummyWalletInit(); diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 6f9294422d..600053ed6f 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -243,10 +244,9 @@ bool StartHTTPRPC() return false; RegisterHTTPHandler("/", true, HTTPReq_JSONRPC); -#ifdef ENABLE_WALLET - // ifdef can be removed once we switch to better endpoint support and API versioning - RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC); -#endif + if (g_wallet_init_interface.HasWalletSupport()) { + RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC); + } struct event_base* eventBase = EventBase(); assert(eventBase); httpRPCTimerInterface = MakeUnique(eventBase); @@ -263,9 +263,9 @@ void StopHTTPRPC() { LogPrint(BCLog::RPC, "Stopping HTTP RPC server\n"); UnregisterHTTPHandler("/", true); -#ifdef ENABLE_WALLET - UnregisterHTTPHandler("/wallet/", false); -#endif + if (g_wallet_init_interface.HasWalletSupport()) { + UnregisterHTTPHandler("/wallet/", false); + } if (httpRPCTimerInterface) { RPCUnsetTimerInterface(httpRPCTimerInterface.get()); httpRPCTimerInterface.reset(); diff --git a/src/init.cpp b/src/init.cpp index e1b08bf252..cc1f7b2e14 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -112,45 +112,6 @@ std::unique_ptr g_connman; std::unique_ptr peerLogic; std::unique_ptr g_banman; -#if !(ENABLE_WALLET) -class DummyWalletInit : public WalletInitInterface { -public: - - void AddWalletOptions() const override; - bool ParameterInteraction() const override {return true;} - void RegisterRPC(CRPCTable &) const override {} - bool Verify() const override {return true;} - bool Open() const override {LogPrintf("No wallet support compiled in!\n"); return true;} - void Start(CScheduler& scheduler) const override {} - void Flush() const override {} - void Stop() const override {} - void Close() const override {} - - // Dash Specific WalletInitInterface InitCoinJoinSettings - void AutoLockMasternodeCollaterals() const override {} - void InitCoinJoinSettings() const override {} - void InitKeePass() const override {} - bool InitAutoBackup() const override {return true;} -}; - -void DummyWalletInit::AddWalletOptions() const -{ - std::vector opts = {"-createwalletbackups=", "-disablewallet", "-instantsendnotify=", - "-keypool=", "-rescan=", "-salvagewallet", "-spendzeroconfchange", "-upgradewallet", - "-wallet=", "-walletbackupsdir=", "-walletbroadcast", "-walletdir=", - "-walletnotify=", "-zapwallettxes=", "-discardfee=", "-fallbackfee=", - "-mintxfee=", "-paytxfee=", "-txconfirmtarget=", "-hdseed=", "-mnemonic=", - "-mnemonicpassphrase=", "-usehd", "-keepass", "-keepassid=", "-keepasskey=", - "-keepassname=", "-keepassport=", "-enablecoinjoin", "-coinjoinamount=", - "-coinjoinautostart", "-coinjoindenomsgoal=", "-coinjoindenomshardcap=", "-coinjoinmultisession", - "-coinjoinrounds=", "-coinjoinsessions=", "-dblogsize=", "-flushwallet", "-privdb", - "-walletrejectlongchains"}; - gArgs.AddHiddenArgs(opts); -} - -const WalletInitInterface& g_wallet_init_interface = DummyWalletInit(); -#endif - static CDSNotificationInterface* pdsNotificationInterface = nullptr; #ifdef WIN32 diff --git a/src/init.h b/src/init.h index af11c36ae5..c87f6f60b7 100644 --- a/src/init.h +++ b/src/init.h @@ -13,9 +13,6 @@ class CScheduler; class CWallet; -class WalletInitInterface; -extern const WalletInitInterface& g_wallet_init_interface; - namespace boost { class thread_group; diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 1397b56679..eec3396cfc 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -24,6 +24,9 @@ class WalletInit : public WalletInitInterface { public: + //! Was the wallet component compiled in. + bool HasWalletSupport() const override {return true;} + //! Return the wallets help message. void AddWalletOptions() const override; diff --git a/src/walletinitinterface.h b/src/walletinitinterface.h index daadeead9a..9dc76ccfb3 100644 --- a/src/walletinitinterface.h +++ b/src/walletinitinterface.h @@ -12,6 +12,8 @@ class CRPCTable; class WalletInitInterface { public: + /** Is the wallet component enabled */ + virtual bool HasWalletSupport() const = 0; /** Get wallet help string */ virtual void AddWalletOptions() const = 0; /** Check wallet parameter interaction */ @@ -40,4 +42,6 @@ public: virtual ~WalletInitInterface() {} }; +extern const WalletInitInterface& g_wallet_init_interface; + #endif // BITCOIN_WALLETINITINTERFACE_H