5 #ifndef BITCOIN_INTERFACES_CHAIN_H 6 #define BITCOIN_INTERFACES_CHAIN_H 8 #include <blockfilter.h> 38 struct ChainstateRole;
120 virtual ~Chain() =
default;
125 virtual std::optional<int>
getHeight() = 0;
177 virtual void findCoins(std::map<COutPoint, Coin>& coins) = 0;
186 virtual bool hasBlocks(
const uint256& block_hash,
int min_height = 0, std::optional<int> max_height = {}) = 0;
209 std::string& err_string) = 0;
212 virtual void getTransactionAncestry(
const Txid& txid,
size_t& ancestors,
size_t& cluster_count,
size_t* ancestorsize =
nullptr,
CAmount* ancestorfees =
nullptr) = 0;
254 virtual void getPackageLimits(
unsigned int& limit_ancestor_count,
unsigned int& limit_descendant_count) = 0;
293 virtual void initMessage(
const std::string& message) = 0;
302 virtual void showProgress(
const std::string& title,
int progress,
bool resume_possible) = 0;
332 virtual std::unique_ptr<Handler>
handleNotifications(std::shared_ptr<Notifications> notifications) = 0;
352 virtual std::vector<common::SettingsValue>
getSettingsList(
const std::string& arg) = 0;
406 virtual bool verify() = 0;
409 virtual bool load() = 0;
415 virtual void stop() = 0;
429 #endif // BITCOIN_INTERFACES_CHAIN_H std::shared_ptr< const CTransaction > CTransactionRef
virtual bool haveBlockOnDisk(int height)=0
Check that the block is available on disk (i.e.
Helper for findBlock to selectively return pieces of block data.
virtual bool deleteRwSettings(const std::string &name, SettingsAction action=SettingsAction::WRITE)=0
Delete a given setting in <datadir>/settings.json.
virtual bool findCommonAncestor(const uint256 &block_hash1, const uint256 &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.
FoundBlock & locator(CBlockLocator &locator)
Return locator if block is in the active chain.
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
virtual void getPackageLimits(unsigned int &limit_ancestor_count, unsigned int &limit_descendant_count)=0
Get the node's package limits.
TxBroadcast
How to broadcast a local transaction.
virtual std::optional< int > getHeight()=0
Get current chain height, not including genesis block (returns 0 if chain only contains genesis block...
virtual ~Notifications()=default
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 void getTransactionAncestry(const Txid &txid, size_t &ancestors, size_t &cluster_count, size_t *ancestorsize=nullptr, CAmount *ancestorfees=nullptr)=0
Calculate mempool ancestor and cluster counts for the given transaction.
virtual void blockConnected(const kernel::ChainstateRole &role, const BlockInfo &block)
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
virtual std::unique_ptr< Handler > handleNotifications(std::shared_ptr< Notifications > notifications)=0
Register handler for notifications.
virtual void registerRpcs()=0
Register rpcs.
virtual void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason)
virtual uint256 getBlockHash(int height)=0
Get block hash. Height must be valid or this function will abort.
virtual CFeeRate mempoolMinFee()=0
Mempool minimum fee.
virtual common::SettingsValue getSetting(const std::string &arg)=0
Get settings value.
virtual CFeeRate relayDustFee()=0
Relay dust fee setting (-dustrelayfee), reflecting lowest rate it's economical to spend...
virtual bool hasBlockFilterIndex(BlockFilterType filter_type)=0
Returns whether a block filter index is available.
virtual std::vector< common::SettingsValue > getSettingsList(const std::string &arg)=0
Get list of settings values.
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal...
Information about chainstate that notifications are sent from.
virtual bool isInitialBlockDownload()=0
Check if in IBD.
virtual std::optional< int > getPruneHeight()=0
Get the current prune height.
virtual void stop()=0
Shut down client.
virtual void updatedBlockTip()
bool disconnect_undo_data
Include undo data with block disconnected notifications.
bool connect_undo_data
Include undo data with block connected notifications.
virtual double guessVerificationProgress(const uint256 &block_hash)=0
Estimate fraction of total transactions verified if blocks up to the specified block hash are verifie...
virtual bool load()=0
Load saved state.
CBlockLocator * m_locator
virtual bool hasDescendantsInMempool(const Txid &txid)=0
Check if transaction has descendants in mempool.
RBFTransactionState
The rbf state of unconfirmed transactions.
virtual void transactionAddedToMempool(const CTransactionRef &tx)
virtual ~ChainClient()=default
int64_t CAmount
Amount in satoshis (Can be negative)
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...
FoundBlock & data(CBlock &data)
Read block data from disk.
Block data sent with blockConnected, blockDisconnected notifications.
NodeContext struct containing references to chain state and connection state.
virtual void chainStateFlushed(const kernel::ChainstateRole &role, const CBlockLocator &locator)
virtual void setMockTime(int64_t time)=0
Set mock time.
virtual bool hasAssumedValidChain()=0
Return true if an assumed-valid snapshot is in use.
virtual void schedulerMockForward(std::chrono::seconds delta_seconds)=0
Mock the scheduler to fast forward in time.
std::function< std::optional< interfaces::SettingsAction >(common::SettingsValue &)> SettingsUpdate
SettingsAction
The action to be taken after updating a settings value.
virtual bool findAncestorByHeight(const uint256 &block_hash, int ancestor_height, const FoundBlock &ancestor_out={})=0
Find ancestor of block at specified height and optionally return ancestor information.
virtual CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation *calc=nullptr)=0
Estimate smart fee.
virtual bool updateRwSetting(const std::string &name, const SettingsUpdate &update_function)=0
Updates a setting in <datadir>/settings.json.
Options specifying which chain notifications are required.
virtual bool overwriteRwSetting(const std::string &name, common::SettingsValue value, SettingsAction action=SettingsAction::WRITE)=0
Replace a setting in <datadir>/settings.json with a new value.
const FoundBlock * m_next_block
FoundBlock & maxTime(int64_t &max_time)
virtual std::unique_ptr< Handler > handleRpc(const CRPCCommand &command)=0
Register handler for RPC.
virtual void start(CScheduler &scheduler)=0
Start client execution and provide a scheduler.
virtual bool findBlock(const uint256 &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
virtual bool broadcastTransaction(const CTransactionRef &tx, const CAmount &max_tx_fee, node::TxBroadcast broadcast_method, std::string &err_string)=0
Process a local transaction, optionally adding it to the mempool and optionally broadcasting it to th...
virtual void waitForNotificationsIfTipChanged(const uint256 &old_tip)=0
Wait for pending notifications to be processed unless block hash points to the current chain tip...
virtual void requestMempoolTransactions(Notifications ¬ifications)=0
Synchronously send transactionAddedToMempool notifications about all current mempool transactions to ...
virtual std::optional< CAmount > calculateCombinedBumpFee(const std::vector< COutPoint > &outpoints, const CFeeRate &target_feerate)=0
Calculate the combined bump fee for an input set per the same strategy.
virtual bool verify()=0
Check for errors before loading.
std::unordered_set< Element, ByteVectorHash > ElementSet
virtual void initWarning(const bilingual_str &message)=0
Send init warning.
virtual bool isInMempool(const Txid &txid)=0
Check if transaction is in mempool.
virtual node::NodeContext * context()
Get internal node context.
bool disconnect_data
Include block data with block disconnected notifications.
virtual bool isReadyToBroadcast()=0
Check if the node is ready to broadcast transactions.
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
virtual bool findAncestorByHash(const uint256 &block_hash, const uint256 &ancestor_hash, const FoundBlock &ancestor_out={})=0
Return whether block descends from a specified ancestor, and optionally return ancestor information...
Interface to let node manage chain clients (wallets, or maybe tools for monitoring and analysis in th...
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual void blockDisconnected(const BlockInfo &block)
Undo information for a CBlock.
virtual void initMessage(const std::string &message)=0
Send init message.
virtual std::map< COutPoint, CAmount > calculateIndividualBumpFees(const std::vector< COutPoint > &outpoints, const CFeeRate &target_feerate)=0
For each outpoint, calculate the fee-bumping cost to spend this outpoint at the specified.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac...
FoundBlock & hash(uint256 &hash)
virtual RBFTransactionState isRBFOptIn(const CTransaction &tx)=0
Check if transaction is RBF opt in.
virtual bool hasBlocks(const uint256 &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 void showProgress(const std::string &title, int progress, bool resume_possible)=0
Send progress indicator.
virtual unsigned int estimateMaxBlocks()=0
Fee estimator max target.
virtual bool shutdownRequested()=0
Check if shutdown requested.
FoundBlock & inActiveChain(bool &in_active_chain)
Return whether block is in the active (most-work) chain.
FoundBlock & height(int &height)
The basic transaction that is broadcasted on the network and contained in blocks. ...
FoundBlock & mtpTime(int64_t &mtp_time)
virtual util::Result< void > checkChainLimits(const CTransactionRef &tx)=0
Check if transaction will pass the mempool's chain limits.
Simple class for background tasks that should be run periodically or once "after a while"...
is a home for public enum and struct type definitions that are used internally by node code...
virtual bool rpcEnableDeprecated(const std::string &method)=0
Check if deprecated RPC is enabled.
virtual common::SettingsValue getRwSetting(const std::string &name)=0
Return <datadir>/settings.json setting value.
virtual void initError(const bilingual_str &message)=0
Send init error.
virtual CFeeRate relayIncrementalFee()=0
Relay incremental fee setting (-incrementalrelayfee), reflecting cost of relay.
virtual CFeeRate relayMinFee()=0
Relay current minimum fee (from -minrelaytxfee and -incrementalrelayfee settings).
virtual void waitForNotifications()=0
Wait for all pending notifications up to this point to be processed.
FoundBlock & nextBlock(const FoundBlock &next_block)
Return next block in the active chain if current block is in the active chain.
FoundBlock & time(int64_t &time)
virtual bool havePruned()=0
Check if any block has been pruned.
virtual std::optional< bool > blockFilterMatchesAny(BlockFilterType filter_type, const uint256 &block_hash, const GCSFilter::ElementSet &filter_set)=0
Returns whether any of the elements match the block via a BIP 157 block filter or std::nullopt if the...