Skip to content

Commit 49fd485

Browse files
committed
Merge #14208: [build] Actually remove ENABLE_WALLET
e4ef4b4 [build] remove #ifdef ENABLE_WALLET from interfaces/node (John Newbery) Pull request description: Adds a couple of redefinitions to dummywallet.cpp. Tree-SHA512: d226bcccc46d089eac88beb54c31f6f18817682994b371f9793a5d28bec5d60dbdffacc8fc281807e25cc7f89da23e1f8f36fd99d12f8a40f77a972840e8c1b4
2 parents 962c302 + e4ef4b4 commit 49fd485

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

src/dummywallet.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <util.h>
77
#include <walletinitinterface.h>
88

9+
class CWallet;
10+
911
class DummyWalletInit : public WalletInitInterface {
1012
public:
1113

@@ -31,3 +33,19 @@ void DummyWalletInit::AddWalletOptions() const
3133
}
3234

3335
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
36+
37+
std::vector<std::shared_ptr<CWallet>> GetWallets()
38+
{
39+
throw std::logic_error("Wallet function called in non-wallet build.");
40+
}
41+
42+
namespace interfaces {
43+
44+
class Wallet;
45+
46+
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
47+
{
48+
throw std::logic_error("Wallet function called in non-wallet build.");
49+
}
50+
51+
} // namespace interfaces

src/interfaces/node.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@
3232
#if defined(HAVE_CONFIG_H)
3333
#include <config/bitcoin-config.h>
3434
#endif
35-
#ifdef ENABLE_WALLET
36-
#include <wallet/fees.h>
37-
#include <wallet/wallet.h>
38-
#define CHECK_WALLET(x) x
39-
#else
40-
#define CHECK_WALLET(x) throw std::logic_error("Wallet function called in non-wallet build.")
41-
#endif
4235

4336
#include <atomic>
4437
#include <boost/thread/thread.hpp>
4538
#include <univalue.h>
4639

40+
class CWallet;
41+
std::vector<std::shared_ptr<CWallet>> GetWallets();
42+
4743
namespace interfaces {
44+
45+
class Wallet;
46+
4847
namespace {
4948

5049
class NodeImpl : public Node
@@ -221,15 +220,11 @@ class NodeImpl : public Node
221220
}
222221
std::vector<std::unique_ptr<Wallet>> getWallets() override
223222
{
224-
#ifdef ENABLE_WALLET
225223
std::vector<std::unique_ptr<Wallet>> wallets;
226224
for (const std::shared_ptr<CWallet>& wallet : GetWallets()) {
227225
wallets.emplace_back(MakeWallet(wallet));
228226
}
229227
return wallets;
230-
#else
231-
throw std::logic_error("Node::getWallets() called in non-wallet build.");
232-
#endif
233228
}
234229
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override
235230
{
@@ -249,8 +244,7 @@ class NodeImpl : public Node
249244
}
250245
std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) override
251246
{
252-
CHECK_WALLET(
253-
return MakeHandler(::uiInterface.LoadWallet_connect([fn](std::shared_ptr<CWallet> wallet) { fn(MakeWallet(wallet)); })));
247+
return MakeHandler(::uiInterface.LoadWallet_connect([fn](std::shared_ptr<CWallet> wallet) { fn(MakeWallet(wallet)); }));
254248
}
255249
std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) override
256250
{

src/interfaces/wallet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ struct WalletTxOut
366366
bool is_spent = false;
367367
};
368368

369-
//! Return implementation of Wallet interface. This function will be undefined
370-
//! in builds where ENABLE_WALLET is false.
369+
//! Return implementation of Wallet interface. This function is defined in
370+
//! dummywallet.cpp and throws if the wallet component is not compiled.
371371
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet);
372372

373373
} // namespace interfaces

0 commit comments

Comments
 (0)