Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/node.cpp
Show All 28 Lines | |||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <warnings.h> | #include <warnings.h> | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include <config/bitcoin-config.h> | #include <config/bitcoin-config.h> | ||||
#endif | #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 <univalue.h> | #include <univalue.h> | ||||
#include <atomic> | #include <atomic> | ||||
class HTTPRPCRequestProcessor; | class HTTPRPCRequestProcessor; | ||||
class CWallet; | |||||
std::vector<std::shared_ptr<CWallet>> GetWallets(); | |||||
namespace interfaces { | namespace interfaces { | ||||
class Wallet; | |||||
namespace { | namespace { | ||||
class NodeImpl : public Node { | class NodeImpl : public Node { | ||||
public: | public: | ||||
NodeImpl() { m_interfaces.chain = MakeChain(); } | NodeImpl() { m_interfaces.chain = MakeChain(); } | ||||
bool parseParameters(int argc, const char *const argv[], | bool parseParameters(int argc, const char *const argv[], | ||||
std::string &error) override { | std::string &error) override { | ||||
return gArgs.ParseParameters(argc, argv, error); | return gArgs.ParseParameters(argc, argv, error); | ||||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | public: | ||||
void rpcUnsetTimerInterface(RPCTimerInterface *iface) override { | void rpcUnsetTimerInterface(RPCTimerInterface *iface) override { | ||||
RPCUnsetTimerInterface(iface); | RPCUnsetTimerInterface(iface); | ||||
} | } | ||||
bool getUnspentOutput(const COutPoint &output, Coin &coin) override { | bool getUnspentOutput(const COutPoint &output, Coin &coin) override { | ||||
LOCK(::cs_main); | LOCK(::cs_main); | ||||
return ::pcoinsTip->GetCoin(output, coin); | return ::pcoinsTip->GetCoin(output, coin); | ||||
} | } | ||||
std::vector<std::unique_ptr<Wallet>> getWallets() override { | std::vector<std::unique_ptr<Wallet>> getWallets() override { | ||||
#ifdef ENABLE_WALLET | |||||
std::vector<std::unique_ptr<Wallet>> wallets; | std::vector<std::unique_ptr<Wallet>> wallets; | ||||
for (const std::shared_ptr<CWallet> &wallet : GetWallets()) { | for (const std::shared_ptr<CWallet> &wallet : GetWallets()) { | ||||
wallets.emplace_back(MakeWallet(wallet)); | wallets.emplace_back(MakeWallet(wallet)); | ||||
} | } | ||||
return wallets; | return wallets; | ||||
#else | |||||
throw std::logic_error( | |||||
"Node::getWallets() called in non-wallet build."); | |||||
#endif | |||||
} | } | ||||
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override { | std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override { | ||||
return MakeHandler(::uiInterface.InitMessage_connect(fn)); | return MakeHandler(::uiInterface.InitMessage_connect(fn)); | ||||
} | } | ||||
std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) override { | std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) override { | ||||
return MakeHandler(::uiInterface.ThreadSafeMessageBox_connect(fn)); | return MakeHandler(::uiInterface.ThreadSafeMessageBox_connect(fn)); | ||||
} | } | ||||
std::unique_ptr<Handler> handleQuestion(QuestionFn fn) override { | std::unique_ptr<Handler> handleQuestion(QuestionFn fn) override { | ||||
return MakeHandler(::uiInterface.ThreadSafeQuestion_connect(fn)); | return MakeHandler(::uiInterface.ThreadSafeQuestion_connect(fn)); | ||||
} | } | ||||
std::unique_ptr<Handler> | std::unique_ptr<Handler> | ||||
handleShowProgress(ShowProgressFn fn) override { | handleShowProgress(ShowProgressFn fn) override { | ||||
return MakeHandler(::uiInterface.ShowProgress_connect(fn)); | return MakeHandler(::uiInterface.ShowProgress_connect(fn)); | ||||
} | } | ||||
std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) override { | 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](std::shared_ptr<CWallet> wallet) { | ||||
fn(MakeWallet(wallet)); | fn(MakeWallet(wallet)); | ||||
}))); | })); | ||||
} | } | ||||
std::unique_ptr<Handler> handleNotifyNumConnectionsChanged( | std::unique_ptr<Handler> handleNotifyNumConnectionsChanged( | ||||
NotifyNumConnectionsChangedFn fn) override { | NotifyNumConnectionsChangedFn fn) override { | ||||
return MakeHandler( | return MakeHandler( | ||||
::uiInterface.NotifyNumConnectionsChanged_connect(fn)); | ::uiInterface.NotifyNumConnectionsChanged_connect(fn)); | ||||
} | } | ||||
std::unique_ptr<Handler> handleNotifyNetworkActiveChanged( | std::unique_ptr<Handler> handleNotifyNetworkActiveChanged( | ||||
NotifyNetworkActiveChangedFn fn) override { | NotifyNetworkActiveChangedFn fn) override { | ||||
Show All 36 Lines |