Skip to content

Commit 4103cc3

Browse files
author
MarcoFalke
committed
Merge bitcoin#14168: Remove ENABLE_WALLET from libbitcoin_server.a
7d038dc [build] remove ENABLE_WALLET ifdef from httprpc.cpp (John Newbery) 3076556 [build] Move dummy wallet into its own .cpp file. (John Newbery) Pull request description: This removes the final instances of ENABLE_WALLET in libbitcoin_server and so completes bitcoin#7965. Tree-SHA512: a49128b7c17f4f69940d5843e6b785f08687efb377b5157d5b267d1205e596eb5c1966f1afb8ab36bcc2491c46252099e3e844c91f5623da8ded2e358d46338d
2 parents 3625187 + 7d038dc commit 4103cc3

File tree

7 files changed

+51
-37
lines changed

7 files changed

+51
-37
lines changed

src/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ libbitcoin_server_a_SOURCES = \
260260
versionbits.cpp \
261261
$(BITCOIN_CORE_H)
262262

263+
if !ENABLE_WALLET
264+
libbitcoin_server_a_SOURCES += dummywallet.cpp
265+
endif
266+
263267
if ENABLE_ZMQ
264268
libbitcoin_zmq_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(ZMQ_CFLAGS)
265269
libbitcoin_zmq_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

src/dummywallet.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2018 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <stdio.h>
6+
#include <util.h>
7+
#include <walletinitinterface.h>
8+
9+
class DummyWalletInit : public WalletInitInterface {
10+
public:
11+
12+
bool HasWalletSupport() const override {return false;}
13+
void AddWalletOptions() const override;
14+
bool ParameterInteraction() const override {return true;}
15+
void RegisterRPC(CRPCTable &) const override {}
16+
bool Verify() const override {return true;}
17+
bool Open() const override {LogPrintf("No wallet support compiled in!\n"); return true;}
18+
void Start(CScheduler& scheduler) const override {}
19+
void Flush() const override {}
20+
void Stop() const override {}
21+
void Close() const override {}
22+
};
23+
24+
void DummyWalletInit::AddWalletOptions() const
25+
{
26+
std::vector<std::string> opts = {"-addresstype", "-changetype", "-disablewallet", "-discardfee=<amt>", "-fallbackfee=<amt>",
27+
"-keypool=<n>", "-mintxfee=<amt>", "-paytxfee=<amt>", "-rescan", "-salvagewallet", "-spendzeroconfchange", "-txconfirmtarget=<n>",
28+
"-upgradewallet", "-wallet=<path>", "-walletbroadcast", "-walletdir=<dir>", "-walletnotify=<cmd>", "-walletrbf", "-zapwallettxes=<mode>",
29+
"-dblogsize=<n>", "-flushwallet", "-privdb", "-walletrejectlongchains"};
30+
gArgs.AddHiddenArgs(opts);
31+
}
32+
33+
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();

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.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,6 @@ static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
7474
std::unique_ptr<CConnman> g_connman;
7575
std::unique_ptr<PeerLogicValidation> peerLogic;
7676

77-
#if !(ENABLE_WALLET)
78-
class DummyWalletInit : public WalletInitInterface {
79-
public:
80-
81-
void AddWalletOptions() const override;
82-
bool ParameterInteraction() const override {return true;}
83-
void RegisterRPC(CRPCTable &) const override {}
84-
bool Verify() const override {return true;}
85-
bool Open() const override {LogPrintf("No wallet support compiled in!\n"); return true;}
86-
void Start(CScheduler& scheduler) const override {}
87-
void Flush() const override {}
88-
void Stop() const override {}
89-
void Close() const override {}
90-
};
91-
92-
void DummyWalletInit::AddWalletOptions() const
93-
{
94-
std::vector<std::string> opts = {"-addresstype", "-changetype", "-disablewallet", "-discardfee=<amt>", "-fallbackfee=<amt>",
95-
"-keypool=<n>", "-mintxfee=<amt>", "-paytxfee=<amt>", "-rescan", "-salvagewallet", "-spendzeroconfchange", "-txconfirmtarget=<n>",
96-
"-upgradewallet", "-wallet=<path>", "-walletbroadcast", "-walletdir=<dir>", "-walletnotify=<cmd>", "-walletrbf", "-zapwallettxes=<mode>",
97-
"-dblogsize=<n>", "-flushwallet", "-privdb", "-walletrejectlongchains"};
98-
gArgs.AddHiddenArgs(opts);
99-
}
100-
101-
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
102-
#endif
103-
10477
#ifdef WIN32
10578
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
10679
// accessing block files don't count towards the fd_set size limit

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)