Bitcoin
Classes | Public Member Functions | List of all members
interfaces::Chain Class Referenceabstract

#include <chain.h>

Inheritance diagram for interfaces::Chain:
interfaces::anonymous_namespace{chain.cpp}::ChainImpl

Classes

class  Lock
 
class  Notifications
 Chain notifications. More...
 

Public Member Functions

virtual ~Chain ()
 
virtual std::unique_ptr< Locklock (bool try_lock=false)=0
 
virtual bool findBlock (const uint256 &hash, CBlock *block=nullptr, int64_t *time=nullptr, int64_t *max_time=nullptr)=0
 
virtual void findCoins (std::map< COutPoint, Coin > &coins)=0
 
virtual double guessVerificationProgress (const uint256 &block_hash)=0
 
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
 
virtual std::unique_ptr< HandlerhandleRpc (const CRPCCommand &command)=0
 
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
 

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:

Constructor & Destructor Documentation

◆ ~Chain()

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

Member Function Documentation

◆ checkChainLimits()

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

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ estimateMaxBlocks()

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

Fee estimator max target.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ estimateSmartFee()

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

Estimate smart fee.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ getAdjustedTime()

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

Get adjusted time.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ handleNotifications()

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

Register handler for notifications.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ hasDescendantsInMempool()

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

Check if transaction has descendants in mempool.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ havePruned()

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

Check if any block has been pruned.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ initError()

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

◆ initMessage()

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

Send init message.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ initWarning()

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

Send init warning.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ isInitialBlockDownload()

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

◆ isRBFOptIn()

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

Check if transaction is RBF opt in.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ isReadyToBroadcast()

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

Check if the node is ready to broadcast transactions.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ loadWallet()

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

Send wallet load notification to the GUI.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ mempoolMinFee()

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

Mempool minimum fee.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ p2pEnabled()

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

Check if p2p enabled.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ relayDustFee()

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

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ relayIncrementalFee()

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

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ relayMinFee()

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

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

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ relayTransaction()

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

Relay transaction.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ rpcEnableDeprecated()

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

Check if deprecated RPC is enabled.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ rpcSerializationFlags()

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

Current RPC serialization flags.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ showProgress()

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

Send progress indicator.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ shutdownRequested()

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

Check if shutdown requested.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.

◆ 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.

Implemented in interfaces::anonymous_namespace{chain.cpp}::ChainImpl.


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