Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2018-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_INTERFACES_NODE_H6#define BITCOIN_INTERFACES_NODE_H8#include <common/settings.h>9#include <consensus/amount.h>10#include <net.h>11#include <net_types.h>12#include <netaddress.h>13#include <netbase.h>14#include <primitives/transaction.h>15#include <uint256.h>16#include <util/log.h>17#include <util/translation.h>19#include <cstddef>20#include <cstdint>21#include <functional>22#include <map>23#include <memory>24#include <optional>25#include <string>26#include <tuple>27#include <vector>29class CFeeRate;30class Coin;31class UniValue;32enum class SynchronizationState;33struct CNodeStateStats;34namespace node {35enum class TransactionError;36struct NodeContext;37} // namespace node39namespace interfaces {40class Handler;41class WalletLoader;42struct BlockTip;44//! Block and header tip information45struct BlockAndHeaderTipInfo46{47int block_height;48int64_t block_time;49int header_height;50int64_t header_time;51double verification_progress;52};54//! External signer interface used by the GUI.55class ExternalSigner56{57public:58virtual ~ExternalSigner() = default;60//! Get signer display name61virtual std::string getName() = 0;62};64//! Top-level interface for a bitcoin node (bitcoind process).65class Node66{67public:68virtual ~Node() = default;70//! Init logging.71virtual void initLogging() = 0;73//! Init parameter interaction.74virtual void initParameterInteraction() = 0;76//! Get warnings.77virtual bilingual_str getWarnings() = 0;79//! Get exit status.80virtual int getExitStatus() = 0;82// Get log flags.83virtual BCLog::CategoryMask getLogCategories() = 0;85//! Initialize app dependencies.86virtual bool baseInitialize() = 0;88//! Start node.89virtual bool appInitMain(interfaces::BlockAndHeaderTipInfo* tip_info = nullptr) = 0;91//! Stop node.92virtual void appShutdown() = 0;94//! Start shutdown.95virtual void startShutdown() = 0;97//! Return whether shutdown was requested.98virtual bool shutdownRequested() = 0;100//! Return whether a particular setting in <datadir>/settings.json is or101//! would be ignored because it is also specified in the command line.102virtual bool isSettingIgnored(const std::string& name) = 0;104//! Return setting value from <datadir>/settings.json or bitcoin.conf.105virtual common::SettingsValue getPersistentSetting(const std::string& name) = 0;107//! Update a setting in <datadir>/settings.json.108virtual void updateRwSetting(const std::string& name, const common::SettingsValue& value) = 0;110//! Force a setting value to be applied, overriding any other configuration111//! source, but not being persisted.112virtual void forceSetting(const std::string& name, const common::SettingsValue& value) = 0;114//! Clear all settings in <datadir>/settings.json and store a backup of115//! previous settings in <datadir>/settings.json.bak.116virtual void resetSettings() = 0;118//! Map port.119virtual void mapPort(bool enable) = 0;121//! Get proxy.122virtual std::optional<Proxy> getProxy(Network net) = 0;124//! Get number of connections.125virtual size_t getNodeCount(ConnectionDirection flags) = 0;127//! Get stats for connected nodes.128using NodesStats = std::vector<std::tuple<CNodeStats, bool, CNodeStateStats>>;129virtual bool getNodesStats(NodesStats& stats) = 0;131//! Get ban map entries.132virtual bool getBanned(banmap_t& banmap) = 0;134//! Ban node.135virtual bool ban(const CNetAddr& net_addr, int64_t ban_time_offset) = 0;137//! Unban node.138virtual bool unban(const CSubNet& ip) = 0;140//! Disconnect node by address.141virtual bool disconnectByAddress(const CNetAddr& net_addr) = 0;143//! Disconnect node by id.144virtual bool disconnectById(NodeId id) = 0;146//! Return list of external signers (attached devices which can sign transactions).147virtual std::vector<std::unique_ptr<ExternalSigner>> listExternalSigners() = 0;149//! Get total bytes recv.150virtual int64_t getTotalBytesRecv() = 0;152//! Get total bytes sent.153virtual int64_t getTotalBytesSent() = 0;155//! Get mempool size.156virtual size_t getMempoolSize() = 0;158//! Get mempool dynamic usage.159virtual size_t getMempoolDynamicUsage() = 0;161//! Get mempool maximum memory usage.162virtual size_t getMempoolMaxUsage() = 0;164//! Get header tip height and time.165virtual bool getHeaderTip(int& height, int64_t& block_time) = 0;167//! Get num blocks.168virtual int getNumBlocks() = 0;170//! Get network local addresses.171virtual std::map<CNetAddr, LocalServiceInfo> getNetLocalAddresses() = 0;173//! Get best block hash.174virtual uint256 getBestBlockHash() = 0;176//! Get last block time.177virtual int64_t getLastBlockTime() = 0;179//! Get verification progress.180virtual double getVerificationProgress() = 0;182//! Is initial block download.183virtual bool isInitialBlockDownload() = 0;185//! Is loading blocks.186virtual bool isLoadingBlocks() = 0;188//! Set network active.189virtual void setNetworkActive(bool active) = 0;191//! Get network active.192virtual bool getNetworkActive() = 0;194//! Get dust relay fee.195virtual CFeeRate getDustRelayFee() = 0;197//! Execute rpc command.198virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0;200//! List rpc commands.201virtual std::vector<std::string> listRpcCommands() = 0;203//! Get unspent output associated with a transaction.204virtual std::optional<Coin> getUnspentOutput(const COutPoint& output) = 0;206//! Broadcast transaction.207virtual node::TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) = 0;209//! Get wallet loader.210virtual WalletLoader& walletLoader() = 0;212//! Register handler for init messages.213using InitMessageFn = std::function<void(const std::string& message)>;214virtual std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) = 0;216//! Register handler for message box messages.217using MessageBoxFn = std::function<void(const bilingual_str& message, unsigned int style)>;218virtual std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) = 0;220//! Register handler for question messages.221using QuestionFn = std::function<bool(const bilingual_str& message,222const std::string& non_interactive_message,223unsigned int style)>;224virtual std::unique_ptr<Handler> handleQuestion(QuestionFn fn) = 0;226//! Register handler for progress messages.227using ShowProgressFn = std::function<void(const std::string& title, int progress, bool resume_possible)>;228virtual std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) = 0;230//! Register handler for wallet loader constructed messages.231using InitWalletFn = std::function<void()>;232virtual std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) = 0;234//! Register handler for number of connections changed messages.235using NotifyNumConnectionsChangedFn = std::function<void(int new_num_connections)>;236virtual std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0;238//! Register handler for network active messages.239using NotifyNetworkActiveChangedFn = std::function<void(bool network_active)>;240virtual std::unique_ptr<Handler> handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn) = 0;242//! Register handler for notify alert messages.243using NotifyAlertChangedFn = std::function<void()>;244virtual std::unique_ptr<Handler> handleNotifyAlertChanged(NotifyAlertChangedFn fn) = 0;246//! Register handler for ban list messages.247using BannedListChangedFn = std::function<void()>;248virtual std::unique_ptr<Handler> handleBannedListChanged(BannedListChangedFn fn) = 0;250//! Register handler for block tip messages.
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.