fedimint_bitcoind

Trait IBitcoindRpc

Source
pub trait IBitcoindRpc: Debug {
Show 13 methods // Required methods fn get_network<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Network>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block_hash<'life0, 'async_trait>( &'life0 self, height: u64, ) -> Pin<Box<dyn Future<Output = Result<BlockHash>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block<'life0, 'life1, 'async_trait>( &'life0 self, block_hash: &'life1 BlockHash, ) -> Pin<Box<dyn Future<Output = Result<Block>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_fee_rate<'life0, 'async_trait>( &'life0 self, confirmation_target: u16, ) -> Pin<Box<dyn Future<Output = Result<Option<Feerate>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn submit_transaction<'life0, 'async_trait>( &'life0 self, transaction: Transaction, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_tx_block_height<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn is_tx_in_block<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, txid: &'life1 Txid, block_hash: &'life2 BlockHash, block_height: u64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn watch_script_history<'life0, 'life1, 'async_trait>( &'life0 self, script: &'life1 ScriptBuf, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_script_history<'life0, 'life1, 'async_trait>( &'life0 self, script: &'life1 ScriptBuf, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_txout_proof<'life0, 'async_trait>( &'life0 self, txid: Txid, ) -> Pin<Box<dyn Future<Output = Result<TxOutProof>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_sync_percentage<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<f64>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_bitcoin_rpc_config(&self) -> BitcoinRpcConfig;
}
Expand description

Trait that allows interacting with the Bitcoin blockchain

Functions may panic if the bitcoind node is not reachable.

Required Methods§

Source

fn get_network<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Network>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the Bitcoin network the node is connected to

Source

fn get_block_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the current block count

Source

fn get_block_hash<'life0, 'async_trait>( &'life0 self, height: u64, ) -> Pin<Box<dyn Future<Output = Result<BlockHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the block hash at a given height

§Panics

If the node does not know a block for that height. Make sure to only query blocks of a height less to the one returned by Self::get_block_count.

While there is a corner case that the blockchain shrinks between these two calls (through on average heavier blocks on a fork) this is prevented by only querying hashes for blocks tailing the chain tip by a certain number of blocks.

Source

fn get_block<'life0, 'life1, 'async_trait>( &'life0 self, block_hash: &'life1 BlockHash, ) -> Pin<Box<dyn Future<Output = Result<Block>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn get_fee_rate<'life0, 'async_trait>( &'life0 self, confirmation_target: u16, ) -> Pin<Box<dyn Future<Output = Result<Option<Feerate>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Estimates the fee rate for a given confirmation target. Make sure that all federation members use the same algorithm to avoid widely diverging results. If the node is not ready yet to return a fee rate estimation this function returns None.

Source

fn submit_transaction<'life0, 'async_trait>( &'life0 self, transaction: Transaction, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Submits a transaction to the Bitcoin network

This operation does not return anything as it never OK to consider its success as final anyway. The caller should be retrying broadcast periodically until it confirms the transaction was actually via other means or decides that is no longer relevant.

Also - most backends considers brodcasting a tx that is already included in the blockchain as an error, which breaks idempotency and requires brittle workarounds just to reliably ignore… just to retry on the higher level anyway.

Implementations of this error should log errors for debugging purposes when it makes sense.

Source

fn get_tx_block_height<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 Txid, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

If a transaction is included in a block, returns the block height. Note: calling this method with bitcoind as a backend must first call watch_script_history or run bitcoind with txindex enabled.

Source

fn is_tx_in_block<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, txid: &'life1 Txid, block_hash: &'life2 BlockHash, block_height: u64, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if a transaction is included in a block

Source

fn watch_script_history<'life0, 'life1, 'async_trait>( &'life0 self, script: &'life1 ScriptBuf, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Watches for a script and returns any transactions associated with it

Should be called at least prior to transactions being submitted or watching may not occur on backends that need it TODO: bitcoind backend is broken <https://github.com/fedimint/fedimint/issues/5329>

Source

fn get_script_history<'life0, 'life1, 'async_trait>( &'life0 self, script: &'life1 ScriptBuf, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get script transaction history

Note: should call watch_script_history at least once, before calling this.

Source

fn get_txout_proof<'life0, 'async_trait>( &'life0 self, txid: Txid, ) -> Pin<Box<dyn Future<Output = Result<TxOutProof>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a proof that a tx is included in the bitcoin blockchain

Source

fn get_sync_percentage<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<f64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the node’s estimated chain sync percentage as a float between 0.0 and 1.0, or None if the node doesn’t support this feature.

Source

fn get_bitcoin_rpc_config(&self) -> BitcoinRpcConfig

Returns the Bitcoin RPC config

Implementors§