5#ifndef BITCOIN_INTERFACES_CHAIN_H
6#define BITCOIN_INTERFACES_CHAIN_H
145 virtual std::optional<int>
179 const FoundBlock &block2_out = {}) = 0;
184 virtual void findCoins(std::map<COutPoint, Coin> &coins) = 0;
194 std::optional<int> max_height = {}) = 0;
202 const Amount &max_tx_fee,
bool relay,
203 std::string &err_string) = 0;
238 bool resume_possible) = 0;
245 uint64_t mempool_sequence) {}
248 uint64_t mempool_sequence) {}
256 virtual std::unique_ptr<Handler>
273 int64_t seconds) = 0;
282 virtual std::vector<util::SettingsValue>
292 bool write =
true) = 0;
const CChainParams & Params()
Return the currently selected parameters.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Fee rate in satoshis per kilobyte: Amount / kB.
Simple class for background tasks that should be run periodically or once "after a while".
virtual void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence)
virtual void chainStateFlushed(const CBlockLocator &locator)
virtual void blockDisconnected(const CBlock &block, int height)
virtual void updatedBlockTip()
virtual void transactionRemovedFromMempool(const CTransactionRef &ptx, MemPoolRemovalReason reason, uint64_t mempool_sequence)
virtual void blockConnected(const CBlock &block, int height)
Interface to let node manage chain clients (wallets, or maybe tools for monitoring and analysis in th...
virtual void stop()=0
Shut down client.
virtual void flush()=0
Save state to disk.
virtual bool load()=0
Load saved state.
virtual void registerRpcs()=0
Register rpcs.
virtual void start(CScheduler &scheduler)=0
Start client execution and provide a scheduler.
virtual bool verify()=0
Check for errors before loading.
virtual void setMockTime(int64_t time)=0
Set mock time.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual void rpcRunLater(const std::string &name, std::function< void()> fn, int64_t seconds)=0
Run function after given number of seconds.
virtual std::unique_ptr< Handler > handleRpc(const CRPCCommand &command)=0
Register handler for RPC.
virtual CBlockLocator getTipLocator()=0
Get locator for the current chain tip.
virtual bool findAncestorByHash(const BlockHash &block_hash, const BlockHash &ancestor_hash, const FoundBlock &ancestor_out={})=0
Return whether block descends from a specified ancestor, and optionally return ancestor information.
virtual bool isInitialBlockDownload()=0
Check if in IBD.
virtual std::optional< int > getHeight()=0
Get current chain height, not including genesis block (returns 0 if chain only contains genesis block...
virtual BlockHash getBlockHash(int height)=0
Get block hash. Height must be valid or this function will abort.
virtual bool rpcEnableDeprecated(const std::string &method)=0
Check if deprecated RPC is enabled.
virtual int rpcSerializationFlags()=0
Current RPC serialization flags.
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
virtual std::unique_ptr< Handler > handleNotifications(std::shared_ptr< Notifications > notifications)=0
Register handler for notifications.
virtual bool findCommonAncestor(const BlockHash &block_hash1, const BlockHash &block_hash2, const FoundBlock &ancestor_out={}, const FoundBlock &block1_out={}, const FoundBlock &block2_out={})=0
Find most recent common ancestor between two blocks and optionally return block information.
virtual bool updateRwSetting(const std::string &name, const util::SettingsValue &value, bool write=true)=0
Write a setting to <datadir>/settings.json.
virtual bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock &block={})=0
Find first block in the chain with timestamp >= the given time and height >= than the given height,...
virtual bool broadcastTransaction(const Config &config, const CTransactionRef &tx, const Amount &max_tx_fee, bool relay, std::string &err_string)=0
Transaction is added to memory pool, if the transaction fee is below the amount specified by max_tx_f...
virtual util::SettingsValue getRwSetting(const std::string &name)=0
Return <datadir>/settings.json setting value.
virtual double guessVerificationProgress(const BlockHash &block_hash)=0
Estimate fraction of total transactions verified if blocks up to the specified block hash are verifie...
virtual const CChainParams & params() const =0
This Chain's parameters.
virtual void showProgress(const std::string &title, int progress, bool resume_possible)=0
Send progress indicator.
virtual bool havePruned()=0
Check if any block has been pruned.
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
virtual bool shutdownRequested()=0
Check if shutdown requested.
virtual bool isReadyToBroadcast()=0
Check if the node is ready to broadcast transactions.
virtual bool hasBlocks(const BlockHash &block_hash, int min_height=0, std::optional< int > max_height={})=0
Return true if data is available for all blocks in the specified range of blocks.
virtual util::SettingsValue getSetting(const std::string &arg)=0
Get settings value.
virtual bool findAncestorByHeight(const BlockHash &block_hash, int ancestor_height, const FoundBlock &ancestor_out={})=0
Find ancestor of block at specified height and optionally return ancestor information.
virtual void initMessage(const std::string &message)=0
Send init message.
virtual std::optional< int > findLocatorFork(const CBlockLocator &locator)=0
Return height of the highest block on chain in common with the locator, which will either be the orig...
virtual bool haveBlockOnDisk(int height)=0
Check that the block is available on disk (i.e.
virtual CFeeRate relayDustFee()=0
Relay dust fee setting (-dustrelayfee), reflecting lowest rate it's economical to spend.
virtual CFeeRate estimateFee() const =0
Estimate fee.
virtual void requestMempoolTransactions(Notifications ¬ifications)=0
Synchronously send transactionAddedToMempool notifications about all current mempool transactions to ...
virtual void initError(const bilingual_str &message)=0
Send init error.
virtual void waitForNotificationsIfTipChanged(const BlockHash &old_tip)=0
Wait for pending notifications to be processed unless block hash points to the current chain tip.
virtual std::vector< util::SettingsValue > getSettingsList(const std::string &arg)=0
Get list of settings values.
virtual void initWarning(const bilingual_str &message)=0
Send init warning.
virtual CFeeRate relayMinFee()=0
Relay current minimum fee (from -minrelaytxfee settings).
Helper for findBlock to selectively return pieces of block data.
FoundBlock & time(int64_t &time)
const FoundBlock * m_next_block
FoundBlock & mtpTime(int64_t &mtp_time)
FoundBlock & nextBlock(const FoundBlock &next_block)
Return next block in the active chain if current block is in the active chain.
FoundBlock & maxTime(int64_t &max_time)
FoundBlock & height(int &height)
FoundBlock & hash(BlockHash &hash)
FoundBlock & inActiveChain(bool &in_active_chain)
Return whether block is in the active (most-work) chain.
FoundBlock & data(CBlock &data)
Read block data from disk.
std::unique_ptr< Chain > MakeChain(node::NodeContext &node, const CChainParams ¶ms)
Return implementation of Chain interface.
std::shared_ptr< const CTransaction > CTransactionRef
A BlockHash is a unqiue identifier for a block.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
NodeContext struct containing references to chain state and connection state.
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.