Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/node.cpp
Show All 21 Lines | |||||
#include <policy/fees.h> | #include <policy/fees.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <support/allocators/secure.h> | #include <support/allocators/secure.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <util/check.h> | |||||
#include <util/ref.h> | #include <util/ref.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | #include <util/translation.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 | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <boost/signals2/signal.hpp> | #include <boost/signals2/signal.hpp> | ||||
class HTTPRPCRequestProcessor; | class HTTPRPCRequestProcessor; | ||||
class CWallet; | |||||
fs::path GetWalletDir(); | |||||
std::vector<fs::path> ListWalletDir(); | |||||
std::vector<std::shared_ptr<CWallet>> GetWallets(); | |||||
std::shared_ptr<CWallet> LoadWallet(const CChainParams &chainParams, | |||||
interfaces::Chain &chain, | |||||
const std::string &name, | |||||
bilingual_str &error, | |||||
std::vector<bilingual_str> &warnings); | |||||
WalletCreationStatus CreateWallet(const CChainParams ¶ms, | |||||
interfaces::Chain &chain, | |||||
const SecureString &passphrase, | |||||
uint64_t wallet_creation_flags, | |||||
const std::string &name, bilingual_str &error, | |||||
std::vector<bilingual_str> &warnings, | |||||
std::shared_ptr<CWallet> &result); | |||||
std::unique_ptr<interfaces::Handler> | |||||
HandleLoadWallet(interfaces::Node::LoadWalletFn load_wallet); | |||||
namespace interfaces { | namespace interfaces { | ||||
namespace { | namespace { | ||||
class NodeImpl : public Node { | class NodeImpl : public Node { | ||||
public: | public: | ||||
NodeImpl(NodeContext *context) { setContext(context); } | NodeImpl(NodeContext *context) { setContext(context); } | ||||
void initLogging() override { InitLogging(*Assert(m_context->args)); } | void initLogging() override { InitLogging(*Assert(m_context->args)); } | ||||
void initParameterInteraction() override { | void initParameterInteraction() override { | ||||
InitParameterInteraction(*Assert(m_context->args)); | InitParameterInteraction(*Assert(m_context->args)); | ||||
▲ Show 20 Lines • Show All 184 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 ::ChainstateActive().CoinsTip().GetCoin(output, coin); | return ::ChainstateActive().CoinsTip().GetCoin(output, coin); | ||||
} | } | ||||
std::string getWalletDir() override { return GetWalletDir().string(); } | WalletClient &walletClient() override { | ||||
std::vector<std::string> listWalletDir() override { | return *Assert(m_context->wallet_client); | ||||
std::vector<std::string> paths; | |||||
for (auto &path : ListWalletDir()) { | |||||
paths.push_back(path.string()); | |||||
} | |||||
return paths; | |||||
} | |||||
std::vector<std::unique_ptr<Wallet>> getWallets() override { | |||||
std::vector<std::unique_ptr<Wallet>> wallets; | |||||
for (auto &client : m_context->chain_clients) { | |||||
auto client_wallets = client->getWallets(); | |||||
std::move(client_wallets.begin(), client_wallets.end(), | |||||
std::back_inserter(wallets)); | |||||
} | |||||
return wallets; | |||||
} | |||||
std::unique_ptr<Wallet> | |||||
loadWallet(const CChainParams ¶ms, const std::string &name, | |||||
bilingual_str &error, | |||||
std::vector<bilingual_str> &warnings) const override { | |||||
return MakeWallet( | |||||
LoadWallet(params, *m_context->chain, name, error, warnings)); | |||||
} | |||||
std::unique_ptr<Wallet> | |||||
createWallet(const CChainParams ¶ms, const SecureString &passphrase, | |||||
uint64_t wallet_creation_flags, const std::string &name, | |||||
bilingual_str &error, std::vector<bilingual_str> &warnings, | |||||
WalletCreationStatus &status) override { | |||||
std::shared_ptr<CWallet> wallet; | |||||
status = CreateWallet(params, *m_context->chain, passphrase, | |||||
wallet_creation_flags, name, error, warnings, | |||||
wallet); | |||||
return MakeWallet(wallet); | |||||
} | } | ||||
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 { | |||||
return HandleLoadWallet(std::move(fn)); | |||||
} | |||||
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 { | ||||
return MakeHandler( | return MakeHandler( | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |