Bitcoin Core  0.18.99
P2P Digital Currency
Classes | Public Member Functions | List of all members
interfaces::Chain Class Referenceabstract

Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to access to the chain state, receive notifications, estimate fees, and submit transactions. More...

#include <chain.h>

Classes

class  Lock
 Interface for querying locked chain state, used by legacy code that assumes state won't change between calls. More...
 
class  Notifications
 Chain notifications. More...
 

Public Member Functions

virtual ~Chain ()
 
virtual std::unique_ptr< Locklock (bool try_lock=false)=0
 Return Lock interface. More...
 
virtual bool findBlock (const uint256 &hash, CBlock *block=nullptr, int64_t *time=nullptr, int64_t *max_time=nullptr)=0
 Return whether node has the block and optionally return block metadata or contents. More...
 
virtual void findCoins (std::map< COutPoint, Coin > &coins)=0
 Look up unspent output information. More...
 
virtual double guessVerificationProgress (const uint256 &block_hash)=0
 Estimate fraction of total transactions verified if blocks up to the specified block hash are verified. More...
 
virtual RBFTransactionState isRBFOptIn (const CTransaction &tx)=0
 Check if transaction is RBF opt in. More...
 
virtual bool hasDescendantsInMempool (const uint256 &txid)=0
 Check if transaction has descendants in mempool. More...
 
virtual void relayTransaction (const uint256 &txid)=0
 Relay transaction. More...
 
virtual void getTransactionAncestry (const uint256 &txid, size_t &ancestors, size_t &descendants)=0
 Calculate mempool ancestor and descendant counts for the given transaction. More...
 
virtual bool checkChainLimits (const CTransactionRef &tx)=0
 Check if transaction will pass the mempool's chain limits. More...
 
virtual CFeeRate estimateSmartFee (int num_blocks, bool conservative, FeeCalculation *calc=nullptr)=0
 Estimate smart fee. More...
 
virtual unsigned int estimateMaxBlocks ()=0
 Fee estimator max target. More...
 
virtual CFeeRate mempoolMinFee ()=0
 Mempool minimum fee. More...
 
virtual CFeeRate relayMinFee ()=0
 Relay current minimum fee (from -minrelaytxfee and -incrementalrelayfee settings). More...
 
virtual CFeeRate relayIncrementalFee ()=0
 Relay incremental fee setting (-incrementalrelayfee), reflecting cost of relay. More...
 
virtual CFeeRate relayDustFee ()=0
 Relay dust fee setting (-dustrelayfee), reflecting lowest rate it's economical to spend. More...
 
virtual bool havePruned ()=0
 Check if any block has been pruned. More...
 
virtual bool p2pEnabled ()=0
 Check if p2p enabled. More...
 
virtual bool isReadyToBroadcast ()=0
 Check if the node is ready to broadcast transactions. More...
 
virtual bool isInitialBlockDownload ()=0
 Check if in IBD. More...
 
virtual bool shutdownRequested ()=0
 Check if shutdown requested. More...
 
virtual int64_t getAdjustedTime ()=0
 Get adjusted time. More...
 
virtual void initMessage (const std::string &message)=0
 Send init message. More...
 
virtual void initWarning (const std::string &message)=0
 Send init warning. More...
 
virtual void initError (const std::string &message)=0
 Send init error. More...
 
virtual void loadWallet (std::unique_ptr< Wallet > wallet)=0
 Send wallet load notification to the GUI. More...
 
virtual void showProgress (const std::string &title, int progress, bool resume_possible)=0
 Send progress indicator. More...
 
virtual std::unique_ptr< HandlerhandleNotifications (Notifications &notifications)=0
 Register handler for notifications. More...
 
virtual void waitForNotificationsIfNewBlocksConnected (const uint256 &old_tip)=0
 Wait for pending notifications to be processed unless block hash points to the current chain tip, or to a possible descendant of the current chain tip that isn't currently connected. More...
 
virtual std::unique_ptr< HandlerhandleRpc (const CRPCCommand &command)=0
 Register handler for RPC. More...
 
virtual bool rpcEnableDeprecated (const std::string &method)=0
 Check if deprecated RPC is enabled. More...
 
virtual void rpcRunLater (const std::string &name, std::function< void()> fn, int64_t seconds)=0
 Run function after given number of seconds. Cancel any previous calls with same name. More...
 
virtual int rpcSerializationFlags ()=0
 Current RPC serialization flags. More...
 
virtual void requestMempoolTransactions (Notifications &notifications)=0
 Synchronously send TransactionAddedToMempool notifications about all current mempool transactions to the specified handler and return after the last one is sent. More...
 

Detailed Description

Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to access to the chain state, receive notifications, estimate fees, and submit transactions.

TODO: Current chain methods are too low level, exposing too much of the internal workings of the bitcoin node, and not being very convenient to use. Chain methods should be cleaned up and simplified over time. Examples:

Definition at line 58 of file chain.h.

Constructor & Destructor Documentation

◆ ~Chain()

virtual interfaces::Chain::~Chain ( )
inlinevirtual

Definition at line 61 of file chain.h.

Member Function Documentation

◆ checkChainLimits()

virtual bool interfaces::Chain::checkChainLimits ( const CTransactionRef tx)
pure virtual

Check if transaction will pass the mempool's chain limits.

◆ estimateMaxBlocks()

virtual unsigned int interfaces::Chain::estimateMaxBlocks ( )
pure virtual

Fee estimator max target.

Here is the caller graph for this function:

◆ estimateSmartFee()

virtual CFeeRate interfaces::Chain::estimateSmartFee ( int  num_blocks,
bool  conservative,
FeeCalculation calc = nullptr 
)
pure virtual

Estimate smart fee.

Here is the caller graph for this function:

◆ findBlock()

virtual bool interfaces::Chain::findBlock ( const uint256 hash,
CBlock block = nullptr,
int64_t *  time = nullptr,
int64_t *  max_time = nullptr 
)
pure virtual

Return whether node has the block and optionally return block metadata or contents.

If a block pointer is provided to retrieve the block contents, and the block exists but doesn't have data (for example due to pruning), the block will be empty and all fields set to null.

Here is the caller graph for this function:

◆ findCoins()

virtual void interfaces::Chain::findCoins ( std::map< COutPoint, Coin > &  coins)
pure virtual

Look up unspent output information.

Returns coins in the mempool and in the current chain UTXO set. Iterates through all the keys in the map and populates the values.

Here is the caller graph for this function:

◆ getAdjustedTime()

virtual int64_t interfaces::Chain::getAdjustedTime ( )
pure virtual

Get adjusted time.

◆ getTransactionAncestry()

virtual void interfaces::Chain::getTransactionAncestry ( const uint256 txid,
size_t &  ancestors,
size_t &  descendants 
)
pure virtual

Calculate mempool ancestor and descendant counts for the given transaction.

Here is the caller graph for this function:

◆ guessVerificationProgress()

virtual double interfaces::Chain::guessVerificationProgress ( const uint256 block_hash)
pure virtual

Estimate fraction of total transactions verified if blocks up to the specified block hash are verified.

◆ handleNotifications()

virtual std::unique_ptr<Handler> interfaces::Chain::handleNotifications ( Notifications notifications)
pure virtual

Register handler for notifications.

Here is the caller graph for this function:

◆ handleRpc()

virtual std::unique_ptr<Handler> interfaces::Chain::handleRpc ( const CRPCCommand command)
pure virtual

Register handler for RPC.

Command is not copied, so reference needs to remain valid until Handler is disconnected.

Here is the caller graph for this function:

◆ hasDescendantsInMempool()

virtual bool interfaces::Chain::hasDescendantsInMempool ( const uint256 txid)
pure virtual

Check if transaction has descendants in mempool.

◆ havePruned()

virtual bool interfaces::Chain::havePruned ( )
pure virtual

Check if any block has been pruned.

Here is the caller graph for this function:

◆ initError()

virtual void interfaces::Chain::initError ( const std::string &  message)
pure virtual

Send init error.

Here is the caller graph for this function:

◆ initMessage()

virtual void interfaces::Chain::initMessage ( const std::string &  message)
pure virtual

Send init message.

Here is the caller graph for this function:

◆ initWarning()

virtual void interfaces::Chain::initWarning ( const std::string &  message)
pure virtual

Send init warning.

◆ isInitialBlockDownload()

virtual bool interfaces::Chain::isInitialBlockDownload ( )
pure virtual

Check if in IBD.

Here is the caller graph for this function:

◆ isRBFOptIn()

virtual RBFTransactionState interfaces::Chain::isRBFOptIn ( const CTransaction tx)
pure virtual

Check if transaction is RBF opt in.

◆ isReadyToBroadcast()

virtual bool interfaces::Chain::isReadyToBroadcast ( )
pure virtual

Check if the node is ready to broadcast transactions.

◆ loadWallet()

virtual void interfaces::Chain::loadWallet ( std::unique_ptr< Wallet wallet)
pure virtual

Send wallet load notification to the GUI.

◆ lock()

virtual std::unique_ptr<Lock> interfaces::Chain::lock ( bool  try_lock = false)
pure virtual

Return Lock interface.

Chain is locked when this is called, and unlocked when the returned interface is freed.

Here is the caller graph for this function:

◆ mempoolMinFee()

virtual CFeeRate interfaces::Chain::mempoolMinFee ( )
pure virtual

Mempool minimum fee.

Here is the caller graph for this function:

◆ p2pEnabled()

virtual bool interfaces::Chain::p2pEnabled ( )
pure virtual

Check if p2p enabled.

◆ relayDustFee()

virtual CFeeRate interfaces::Chain::relayDustFee ( )
pure virtual

Relay dust fee setting (-dustrelayfee), reflecting lowest rate it's economical to spend.

Here is the caller graph for this function:

◆ relayIncrementalFee()

virtual CFeeRate interfaces::Chain::relayIncrementalFee ( )
pure virtual

Relay incremental fee setting (-incrementalrelayfee), reflecting cost of relay.

◆ relayMinFee()

virtual CFeeRate interfaces::Chain::relayMinFee ( )
pure virtual

Relay current minimum fee (from -minrelaytxfee and -incrementalrelayfee settings).

Here is the caller graph for this function:

◆ relayTransaction()

virtual void interfaces::Chain::relayTransaction ( const uint256 txid)
pure virtual

Relay transaction.

◆ requestMempoolTransactions()

virtual void interfaces::Chain::requestMempoolTransactions ( Notifications notifications)
pure virtual

Synchronously send TransactionAddedToMempool notifications about all current mempool transactions to the specified handler and return after the last one is sent.

These notifications aren't coordinated with async notifications sent by handleNotifications, so out of date async notifications from handleNotifications can arrive during and after synchronous notifications from requestMempoolTransactions. Clients need to be prepared to handle this by ignoring notifications about unknown removed transactions and already added new transactions.

Here is the caller graph for this function:

◆ rpcEnableDeprecated()

virtual bool interfaces::Chain::rpcEnableDeprecated ( const std::string &  method)
pure virtual

Check if deprecated RPC is enabled.

Here is the caller graph for this function:

◆ rpcRunLater()

virtual void interfaces::Chain::rpcRunLater ( const std::string &  name,
std::function< void()>  fn,
int64_t  seconds 
)
pure virtual

Run function after given number of seconds. Cancel any previous calls with same name.

Here is the caller graph for this function:

◆ rpcSerializationFlags()

virtual int interfaces::Chain::rpcSerializationFlags ( )
pure virtual

Current RPC serialization flags.

Here is the caller graph for this function:

◆ showProgress()

virtual void interfaces::Chain::showProgress ( const std::string &  title,
int  progress,
bool  resume_possible 
)
pure virtual

Send progress indicator.

Here is the caller graph for this function:

◆ shutdownRequested()

virtual bool interfaces::Chain::shutdownRequested ( )
pure virtual

Check if shutdown requested.

◆ waitForNotificationsIfNewBlocksConnected()

virtual void interfaces::Chain::waitForNotificationsIfNewBlocksConnected ( const uint256 old_tip)
pure virtual

Wait for pending notifications to be processed unless block hash points to the current chain tip, or to a possible descendant of the current chain tip that isn't currently connected.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: