diff --git a/src/dummywallet.cpp b/src/dummywallet.cpp --- a/src/dummywallet.cpp +++ b/src/dummywallet.cpp @@ -6,6 +6,8 @@ #include #include +class CWallet; + class DummyWalletInit : public WalletInitInterface { public: bool HasWalletSupport() const override { return false; } @@ -29,3 +31,17 @@ } const WalletInitInterface &g_wallet_init_interface = DummyWalletInit(); + +std::vector> GetWallets() { + throw std::logic_error("Wallet function called in non-wallet build."); +} + +namespace interfaces { + +class Wallet; + +std::unique_ptr MakeWallet(const std::shared_ptr &wallet) { + throw std::logic_error("Wallet function called in non-wallet build."); +} + +} // namespace interfaces diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -34,22 +34,19 @@ #if defined(HAVE_CONFIG_H) #include #endif -#ifdef ENABLE_WALLET -#include -#include -#define CHECK_WALLET(x) x -#else -#define CHECK_WALLET(x) \ - throw std::logic_error("Wallet function called in non-wallet build.") -#endif #include #include class HTTPRPCRequestProcessor; +class CWallet; +std::vector> GetWallets(); namespace interfaces { + +class Wallet; + namespace { class NodeImpl : public Node { @@ -247,16 +244,11 @@ return ::pcoinsTip->GetCoin(output, coin); } std::vector> getWallets() override { -#ifdef ENABLE_WALLET std::vector> wallets; for (const std::shared_ptr &wallet : GetWallets()) { wallets.emplace_back(MakeWallet(wallet)); } return wallets; -#else - throw std::logic_error( - "Node::getWallets() called in non-wallet build."); -#endif } std::unique_ptr handleInitMessage(InitMessageFn fn) override { return MakeHandler(::uiInterface.InitMessage_connect(fn)); @@ -272,10 +264,10 @@ return MakeHandler(::uiInterface.ShowProgress_connect(fn)); } std::unique_ptr handleLoadWallet(LoadWalletFn fn) override { - CHECK_WALLET(return MakeHandler(::uiInterface.LoadWallet_connect( + return MakeHandler(::uiInterface.LoadWallet_connect( [fn](std::shared_ptr wallet) { fn(MakeWallet(wallet)); - }))); + })); } std::unique_ptr handleNotifyNumConnectionsChanged( NotifyNumConnectionsChangedFn fn) override { diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -357,8 +357,8 @@ bool is_spent = false; }; -//! Return implementation of Wallet interface. This function will be undefined -//! in builds where ENABLE_WALLET is false. +//! Return implementation of Wallet interface. This function is defined in +//! dummywallet.cpp and throws if the wallet component is not compiled. std::unique_ptr MakeWallet(const std::shared_ptr &wallet); } // namespace interfaces