33 #include <validation.h> 36 #if defined(HAVE_CONFIG_H) 37 #include <config/bitcoin-config.h> 42 #include <boost/signals2/signal.hpp> 48 std::vector<std::shared_ptr<CWallet>>
GetWallets();
51 const std::string &
name,
53 std::vector<bilingual_str> &warnings);
57 uint64_t wallet_creation_flags,
59 std::vector<bilingual_str> &warnings,
60 std::shared_ptr<CWallet> &result);
61 std::unique_ptr<interfaces::Handler>
68 class NodeImpl :
public Node {
70 NodeImpl(
NodeContext *context) { setContext(context); }
72 void initParameterInteraction()
override {
75 std::string getWarnings()
override {
return GetWarnings(
true); }
76 bool baseInitialize(
Config &config)
override {
85 return AppInitMain(config, rpcServer, httpRPCRequestProcessor,
88 void appShutdown()
override {
94 void mapPort(
bool use_upnp)
override {
109 bool getNodesStats(NodesStats &stats)
override {
113 std::vector<CNodeStats> stats_temp;
116 stats.reserve(stats_temp.size());
117 for (
auto &node_stats_temp : stats_temp) {
118 stats.emplace_back(std::move(node_stats_temp),
false,
125 for (
auto &node_stats : stats) {
126 std::get<1>(node_stats) =
128 std::get<2>(node_stats));
135 bool getBanned(
banmap_t &banmap)
override {
142 bool ban(
const CNetAddr &net_addr, int64_t ban_time_offset)
override {
149 bool unban(
const CSubNet &ip)
override {
156 bool disconnectByAddress(
const CNetAddr &net_addr)
override {
162 bool disconnectById(
NodeId id)
override {
168 int64_t getTotalBytesRecv()
override {
172 int64_t getTotalBytesSent()
override {
176 size_t getMempoolSize()
override {
179 size_t getMempoolDynamicUsage()
override {
183 bool getHeaderTip(
int &height, int64_t &block_time)
override {
192 int getNumBlocks()
override {
196 int64_t getLastBlockTime()
override {
204 double getVerificationProgress()
override {
212 bool isInitialBlockDownload()
override {
217 void setNetworkActive(
bool active)
override {
222 bool getNetworkActive()
override {
225 CFeeRate estimateSmartFee()
override {
232 const std::string &uri)
override {
235 req.strMethod = command;
239 std::vector<std::string> listRpcCommands()
override {
248 bool getUnspentOutput(
const COutPoint &output,
Coin &coin)
override {
252 std::string getWalletDir()
override {
return GetWalletDir().string(); }
253 std::vector<std::string> listWalletDir()
override {
254 std::vector<std::string> paths;
256 paths.push_back(path.string());
260 std::vector<std::unique_ptr<Wallet>> getWallets()
override {
261 std::vector<std::unique_ptr<Wallet>> wallets;
263 auto client_wallets = client->getWallets();
264 std::move(client_wallets.begin(), client_wallets.end(),
265 std::back_inserter(wallets));
269 std::unique_ptr<Wallet>
272 std::vector<bilingual_str> &warnings)
const override {
276 std::unique_ptr<Wallet>
278 uint64_t wallet_creation_flags,
const std::string &name,
281 std::shared_ptr<CWallet> wallet;
283 wallet_creation_flags, name, error, warnings,
287 std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn)
override {
290 std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn)
override {
293 std::unique_ptr<Handler> handleQuestion(QuestionFn fn)
override {
296 std::unique_ptr<Handler>
297 handleShowProgress(ShowProgressFn fn)
override {
300 std::unique_ptr<Handler> handleLoadWallet(
LoadWalletFn fn)
override {
303 std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(
304 NotifyNumConnectionsChangedFn fn)
override {
306 ::
uiInterface.NotifyNumConnectionsChanged_connect(fn));
308 std::unique_ptr<Handler> handleNotifyNetworkActiveChanged(
309 NotifyNetworkActiveChangedFn fn)
override {
311 ::
uiInterface.NotifyNetworkActiveChanged_connect(fn));
313 std::unique_ptr<Handler>
314 handleNotifyAlertChanged(NotifyAlertChangedFn fn)
override {
317 std::unique_ptr<Handler>
318 handleBannedListChanged(BannedListChangedFn fn)
override {
321 std::unique_ptr<Handler>
322 handleNotifyBlockTip(NotifyBlockTipFn fn)
override {
326 fn(sync_state, block->nHeight, block->GetBlockTime(),
327 GuessVerificationProgress(Params().TxData(), block));
330 std::unique_ptr<Handler>
331 handleNotifyHeaderTip(NotifyHeaderTipFn fn)
override {
336 fn(sync_state, block->nHeight, block->GetBlockTime(), 0);
354 return std::make_unique<NodeImpl>(context);
std::vector< std::unique_ptr< interfaces::ChainClient > > chain_clients
void InitLogging(const ArgsManager &args)
Initialize global loggers.
SynchronizationState
Current sync state passed to tip changed callbacks.
int64_t GetBlockTime() const
#define TRY_LOCK(cs, name)
void Shutdown(NodeContext &node)
std::unique_ptr< BanMan > banman
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
size_t DynamicMemoryUsage() const
int Height() const
Return the maximal height in the chain.
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
std::unique_ptr< interfaces::Chain > chain
unsigned long size() const
CFeeRate estimateFee() const
std::shared_ptr< CWallet > LoadWallet(const CChainParams &chainParams, interfaces::Chain &chain, const std::string &name, bilingual_str &error, std::vector< bilingual_str > &warnings)
const CBlock & GenesisBlock() const
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
std::unique_ptr< Handler > MakeHandler(boost::signals2::connection connection)
Return handler wrapping a boost signal connection.
virtual const CChainParams & GetChainParams() const =0
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
CChainState & ChainstateActive()
interfaces::Chain & chain() const
Interface for accessing chain state.
std::vector< std::shared_ptr< CWallet > > GetWallets()
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
NodeContext struct containing references to chain state and connection state.
std::unique_ptr< CConnman > connman
void Interrupt(NodeContext &node)
Interrupt threads.
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
RecursiveMutex cs_main
Global state.
std::unique_ptr< interfaces::Handler > HandleLoadWallet(interfaces::Node::LoadWalletFn load_wallet)
Class for registering and managing all RPC calls.
std::atomic_bool fImporting
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
std::function< void(std::unique_ptr< Wallet > wallet)> LoadWalletFn
Register handler for load wallet messages.
An outpoint - a combination of a transaction hash and an index n into its vout.
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< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
Return implementation of Wallet interface.
Type-safe dynamic reference.
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set the factory function for timer, but only, if unset.
std::atomic_bool fReindex
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess how far we are in the verification process at the given block index require cs_main if pindex h...
bool AppInitBasicSetup(ArgsManager &args)
Initialize bitcoin: Basic context setup.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
bool IsInitialBlockDownload() const
Check whether we are doing an initial block download (synchronizing from disk or network) ...
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Fee rate in satoshis per kilobyte: Amount / kB.
std::string GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::map< CSubNet, CBanEntry > banmap_t
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
bool AppInitLockDataDirectory()
Lock bitcoin data directory.
UniValue execute(Config &config, const JSONRPCRequest &request) const
Execute a method.
CClientUIInterface uiInterface
int nHeight
height of the entry in the chain. The genesis block has height 0
std::vector< std::string > listCommands() const
Returns a list of registered commands.
std::unique_ptr< Node > MakeNode(NodeContext *context)
Return implementation of Node interface.
bool error(const char *fmt, const Args &... args)
void InitParameterInteraction(ArgsManager &args)
Parameter interaction: change current parameters depending on various rules.
bool AppInitMain(Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor, NodeContext &node)
Bitcoin main initialization.
std::vector< fs::path > ListWalletDir()
#define Assert(val)
Identity function.
bool AppInitParameterInteraction(Config &config, const ArgsManager &args)
Initialization: parameter interaction.
std::unique_ptr< Chain > MakeChain(NodeContext &node, const CChainParams ¶ms)
Return implementation of Chain interface.