29 #include <validation.h> 32 #if defined(HAVE_CONFIG_H) 37 #include <boost/thread/thread.hpp> 43 std::vector<std::shared_ptr<CWallet>>
GetWallets();
51 class NodeImpl :
public Node
53 bool parseParameters(
int argc,
const char*
const argv[], std::string&
error)
override 58 bool softSetArg(
const std::string& arg,
const std::string& value)
override {
return gArgs.
SoftSetArg(arg, value); }
59 bool softSetBoolArg(
const std::string& arg,
bool value)
override {
return gArgs.
SoftSetBoolArg(arg, value); }
60 void selectParams(
const std::string& network)
override {
SelectParams(network); }
64 std::string getWarnings(
const std::string& type)
override {
return GetWarnings(type); }
66 bool baseInitialize()
override 71 bool appInitMain()
override {
return AppInitMain(); }
72 void appShutdown()
override 79 void mapPort(
bool use_upnp)
override 94 bool getNodesStats(NodesStats& stats)
override 99 std::vector<CNodeStats> stats_temp;
102 stats.reserve(stats_temp.size());
103 for (
auto& node_stats_temp : stats_temp) {
104 stats.emplace_back(std::move(node_stats_temp),
false,
CNodeStateStats());
110 for (
auto& node_stats : stats) {
111 std::get<1>(node_stats) =
119 bool getBanned(
banmap_t& banmap)
override 127 bool ban(
const CNetAddr& net_addr,
BanReason reason, int64_t ban_time_offset)
override 130 g_connman->Ban(net_addr, reason, ban_time_offset);
135 bool unban(
const CSubNet& ip)
override 143 bool disconnect(
NodeId id)
override 150 int64_t getTotalBytesRecv()
override {
return g_connman ?
g_connman->GetTotalBytesRecv() : 0; }
151 int64_t getTotalBytesSent()
override {
return g_connman ?
g_connman->GetTotalBytesSent() : 0; }
154 bool getHeaderTip(
int& height, int64_t& block_time)
override 164 int getNumBlocks()
override 169 int64_t getLastBlockTime()
override 177 double getVerificationProgress()
override 189 void setNetworkActive(
bool active)
override 195 bool getNetworkActive()
override {
return g_connman &&
g_connman->GetNetworkActive(); }
197 CFeeRate estimateSmartFee(
int num_blocks,
bool conservative,
int* returned_target =
nullptr)
override 201 if (returned_target) {
207 UniValue executeRpc(
const std::string& command,
const UniValue& params,
const std::string& uri)
override 218 bool getUnspentOutput(
const COutPoint& output,
Coin& coin)
override 223 std::string getWalletDir()
override 227 std::vector<std::string> listWalletDir()
override 229 std::vector<std::string> paths;
231 paths.push_back(path.string());
235 std::vector<std::unique_ptr<Wallet>> getWallets()
override 237 std::vector<std::unique_ptr<Wallet>> wallets;
238 for (
const std::shared_ptr<CWallet>& wallet :
GetWallets()) {
243 std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn)
override 247 std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn)
override 251 std::unique_ptr<Handler> handleQuestion(QuestionFn fn)
override 259 std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn)
override 261 return MakeHandler(::
uiInterface.LoadWallet_connect([fn](std::shared_ptr<CWallet> wallet) { fn(MakeWallet(wallet)); }));
263 std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn)
override 267 std::unique_ptr<Handler> handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn)
override 271 std::unique_ptr<Handler> handleNotifyAlertChanged(NotifyAlertChangedFn fn)
override 275 std::unique_ptr<Handler> handleBannedListChanged(BannedListChangedFn fn)
override 279 std::unique_ptr<Handler> handleNotifyBlockTip(NotifyBlockTipFn fn)
override 282 fn(initial_download, block->nHeight, block->GetBlockTime(),
283 GuessVerificationProgress(Params().TxData(), block));
286 std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn)
override 290 fn(initial_download, block->nHeight, block->GetBlockTime(),
291 GuessVerificationProgress(Params().TxData(), block));
298 std::unique_ptr<Node>
MakeNode() {
return MakeUnique<NodeImpl>(); }
bool ReadConfigFiles(std::string &error, bool ignore_invalid_keys=false)
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
void InitLogging()
Initialize global loggers.
int64_t GetBlockTime() const
#define TRY_LOCK(cs, name)
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool AppInitMain()
Bitcoin core main initialization.
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
CAmount maxTxFee
Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendra...
size_t DynamicMemoryUsage() const
int Height() const
Return the maximal height in the chain.
void Interrupt()
Interrupt threads.
const CBlock & GenesisBlock() const
bool ParseParameters(int argc, const char *const argv[], std::string &error)
std::unique_ptr< Handler > MakeHandler(boost::signals2::connection connection)
Return handler wrapping a boost signal connection.
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
bool AppInitBasicSetup()
Initialize bitcoin core: Basic context setup.
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
std::unique_ptr< CCoinsViewCache > pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
int64_t CAmount
Amount in satoshis (Can be negative)
UniValue execute(const JSONRPCRequest &request) const
Execute a method.
void InitParameterInteraction()
Parameter interaction: change current parameters depending on various rules.
CBlockPolicyEstimator feeEstimator
std::vector< std::shared_ptr< CWallet > > GetWallets()
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
std::map< CSubNet, CBanEntry > banmap_t
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, bool conservative) const
Estimate feerate needed to get be included in a block within confTarget blocks.
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
uint32_t GetCategoryMask() const
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network) ...
std::atomic_bool fImporting
An outpoint - a combination of a transaction hash and an index n into its vout.
std::unique_ptr< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
Return implementation of Wallet interface.
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set the factory function for timer, but only, if unset.
bool AppInitParameterInteraction()
Initialization: parameter interaction.
std::atomic_bool fReindex
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
void SetupServerArgs()
Setup the arguments for gArgs.
std::unique_ptr< Node > MakeNode()
Return implementation of Node interface.
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...
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
std::function< void(const std::string &title, int progress)> ShowProgressFn
Register handler for show progress messages.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Fee rate in satoshis per kilobyte: CAmount / kB.
std::unique_ptr< CConnman > g_connman
bool error(const char *fmt, const Args &... args)
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
bool AppInitLockDataDirectory()
Lock bitcoin core data directory.
CClientUIInterface uiInterface
int nHeight
height of the entry in the chain. The genesis block has height 0
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
std::vector< std::string > listCommands() const
Returns a list of registered commands.
BCLog::Logger *const g_logger
NOTE: the logger instances is leaked on exit.
std::vector< fs::path > ListWalletDir()