diff --git a/src/interfaces/node.h b/src/interfaces/node.h --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -6,6 +6,7 @@ #define BITCOIN_INTERFACES_NODE_H #include // For banmap_t +#include // For Amount #include // For HelpMessageMode #include // For CConnman::NumConnections #include // For Network @@ -148,6 +149,9 @@ //! Get network active. virtual bool getNetworkActive() = 0; + //! Get max tx fee. + virtual Amount getMaxTxFee() = 0; + //! Execute rpc command. virtual UniValue executeRpc(Config &config, const std::string &command, const UniValue ¶ms, @@ -162,6 +166,9 @@ //! Unset RPC timer interface. virtual void rpcUnsetTimerInterface(RPCTimerInterface *iface) = 0; + //! Return interfaces for accessing wallets (if any). + virtual std::vector> getWallets() = 0; + //! Register handler for init messages. using InitMessageFn = std::function; virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -29,6 +30,7 @@ #include #endif #ifdef ENABLE_WALLET +#include #define CHECK_WALLET(x) x #else #define CHECK_WALLET(x) \ @@ -40,7 +42,6 @@ #include -class CWallet; class HTTPRPCRequestProcessor; namespace interfaces { @@ -207,6 +208,7 @@ bool getNetworkActive() override { return g_connman && g_connman->GetNetworkActive(); } + Amount getMaxTxFee() override { return ::maxTxFee; } UniValue executeRpc(Config &config, const std::string &command, const UniValue ¶ms, const std::string &uri) override { @@ -225,6 +227,18 @@ void rpcUnsetTimerInterface(RPCTimerInterface *iface) override { RPCUnsetTimerInterface(iface); } + std::vector> getWallets() override { +#ifdef ENABLE_WALLET + std::vector> wallets; + for (CWalletRef wallet : ::vpwallets) { + wallets.emplace_back(MakeWallet(*wallet)); + } + return wallets; +#else + throw std::logic_error( + "Node::getWallets() called in non-wallet build."); +#endif + } std::unique_ptr handleInitMessage(InitMessageFn fn) override { return MakeHandler(::uiInterface.InitMessage.connect(fn)); } diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -5,25 +5,211 @@ #ifndef BITCOIN_INTERFACES_WALLET_H #define BITCOIN_INTERFACES_WALLET_H +#include // For Amount +#include