Skip to content

Commit 7d038dc

Browse files
committed
[build] remove ENABLE_WALLET ifdef from httprpc.cpp
1 parent 3076556 commit 7d038dc

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

src/dummywallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class DummyWalletInit : public WalletInitInterface {
1010
public:
1111

12+
bool HasWalletSupport() const override {return false;}
1213
void AddWalletOptions() const override;
1314
bool ParameterInteraction() const override {return true;}
1415
void RegisterRPC(CRPCTable &) const override {}

src/httprpc.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <util.h>
1515
#include <utilstrencodings.h>
1616
#include <ui_interface.h>
17+
#include <walletinitinterface.h>
1718
#include <crypto/hmac_sha256.h>
1819
#include <stdio.h>
1920

@@ -240,10 +241,9 @@ bool StartHTTPRPC()
240241
return false;
241242

242243
RegisterHTTPHandler("/", true, HTTPReq_JSONRPC);
243-
#ifdef ENABLE_WALLET
244-
// ifdef can be removed once we switch to better endpoint support and API versioning
245-
RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC);
246-
#endif
244+
if (g_wallet_init_interface.HasWalletSupport()) {
245+
RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC);
246+
}
247247
struct event_base* eventBase = EventBase();
248248
assert(eventBase);
249249
httpRPCTimerInterface = MakeUnique<HTTPRPCTimerInterface>(eventBase);
@@ -260,9 +260,9 @@ void StopHTTPRPC()
260260
{
261261
LogPrint(BCLog::RPC, "Stopping HTTP RPC server\n");
262262
UnregisterHTTPHandler("/", true);
263-
#ifdef ENABLE_WALLET
264-
UnregisterHTTPHandler("/wallet/", false);
265-
#endif
263+
if (g_wallet_init_interface.HasWalletSupport()) {
264+
UnregisterHTTPHandler("/wallet/", false);
265+
}
266266
if (httpRPCTimerInterface) {
267267
RPCUnsetTimerInterface(httpRPCTimerInterface.get());
268268
httpRPCTimerInterface.reset();

src/init.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
class CScheduler;
1414
class CWallet;
1515

16-
class WalletInitInterface;
17-
extern const WalletInitInterface& g_wallet_init_interface;
18-
1916
namespace boost
2017
{
2118
class thread_group;

src/wallet/init.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
class WalletInit : public WalletInitInterface {
2020
public:
2121

22+
//! Was the wallet component compiled in.
23+
bool HasWalletSupport() const override {return true;}
24+
2225
//! Return the wallets help message.
2326
void AddWalletOptions() const override;
2427

src/walletinitinterface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class CRPCTable;
1212

1313
class WalletInitInterface {
1414
public:
15+
/** Is the wallet component enabled */
16+
virtual bool HasWalletSupport() const = 0;
1517
/** Get wallet help string */
1618
virtual void AddWalletOptions() const = 0;
1719
/** Check wallet parameter interaction */
@@ -34,4 +36,6 @@ class WalletInitInterface {
3436
virtual ~WalletInitInterface() {}
3537
};
3638

39+
extern const WalletInitInterface& g_wallet_init_interface;
40+
3741
#endif // BITCOIN_WALLETINITINTERFACE_H

0 commit comments

Comments
 (0)