Skip to content

Commit

Permalink
Merge #14208: [build] Actually remove ENABLE_WALLET
Browse files Browse the repository at this point in the history
Summary:
e4ef4b459548b4032b9da03b3103525f935acb82 [build] remove #ifdef ENABLE_WALLET from interfaces/node (John Newbery)

Pull request description:

  Adds a couple of redefinitions to dummywallet.cpp.

Tree-SHA512: d226bcccc46d089eac88beb54c31f6f18817682994b371f9793a5d28bec5d60dbdffacc8fc281807e25cc7f89da23e1f8f36fd99d12f8a40f77a972840e8c1b4

Backport of Core [[bitcoin/bitcoin#14208 | PR14208]]

Test Plan:
  cmake -GNinja -DBUILD_BITCOIN_WALLET=OFF ..
  ninja
  ninja check
  ninja check-functional
  ./bitcoind
  ./bitcoin-cli getnewaddress
Verify rpc fails because there is no wallet.

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5518
  • Loading branch information
laanwj authored and ftrader committed Apr 23, 2020
1 parent 8e40794 commit fba296c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
16 changes: 16 additions & 0 deletions src/dummywallet.cpp
Expand Up @@ -6,6 +6,8 @@
#include <util/system.h>
#include <walletinitinterface.h>

class CWallet;

class DummyWalletInit : public WalletInitInterface {
public:
bool HasWalletSupport() const override { return false; }
Expand All @@ -29,3 +31,17 @@ void DummyWalletInit::AddWalletOptions() const {
}

const WalletInitInterface &g_wallet_init_interface = DummyWalletInit();

std::vector<std::shared_ptr<CWallet>> GetWallets() {
throw std::logic_error("Wallet function called in non-wallet build.");
}

namespace interfaces {

class Wallet;

std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet> &wallet) {
throw std::logic_error("Wallet function called in non-wallet build.");
}

} // namespace interfaces
22 changes: 7 additions & 15 deletions src/interfaces/node.cpp
Expand Up @@ -34,23 +34,20 @@
#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif
#ifdef ENABLE_WALLET
#include <wallet/fees.h>
#include <wallet/wallet.h>
#define CHECK_WALLET(x) x
#else
#define CHECK_WALLET(x) \
throw std::logic_error("Wallet function called in non-wallet build.")
#endif

#include <boost/thread/thread.hpp>
#include <univalue.h>

#include <atomic>

class HTTPRPCRequestProcessor;
class CWallet;
std::vector<std::shared_ptr<CWallet>> GetWallets();

namespace interfaces {

class Wallet;

namespace {

class NodeImpl : public Node {
Expand Down Expand Up @@ -248,16 +245,11 @@ namespace {
return ::pcoinsTip->GetCoin(output, coin);
}
std::vector<std::unique_ptr<Wallet>> getWallets() override {
#ifdef ENABLE_WALLET
std::vector<std::unique_ptr<Wallet>> wallets;
for (const std::shared_ptr<CWallet> &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<Handler> handleInitMessage(InitMessageFn fn) override {
return MakeHandler(::uiInterface.InitMessage_connect(fn));
Expand All @@ -273,10 +265,10 @@ namespace {
return MakeHandler(::uiInterface.ShowProgress_connect(fn));
}
std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) override {
CHECK_WALLET(return MakeHandler(::uiInterface.LoadWallet_connect(
return MakeHandler(::uiInterface.LoadWallet_connect(
[fn](std::shared_ptr<CWallet> wallet) {
fn(MakeWallet(wallet));
})));
}));
}
std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(
NotifyNumConnectionsChangedFn fn) override {
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/wallet.h
Expand Up @@ -358,8 +358,8 @@ struct WalletTxOut {
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<Wallet> MakeWallet(const std::shared_ptr<CWallet> &wallet);

} // namespace interfaces
Expand Down

0 comments on commit fba296c

Please sign in to comment.