pub trait IBitcoindRpc: Debug {
    // 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_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 watch_script_history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        script: &'life1 Script
    ) -> 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 Script
    ) -> 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;
}
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_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,

Check if a transaction is included in a block

source

fn watch_script_history<'life0, 'life1, 'async_trait>( &'life0 self, script: &'life1 Script ) -> 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 once prior to transactions being submitted or watching may not occur on backends that need it

source

fn get_script_history<'life0, 'life1, 'async_trait>( &'life0 self, script: &'life1 Script ) -> 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 (and ideally only 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

Implementors§