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 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_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§
Sourcefn 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_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
Sourcefn 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_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
Sourcefn 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_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.
Sourcefn 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 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
.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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
Sourcefn 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 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>
Sourcefn 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_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.
Sourcefn 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_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
Sourcefn get_bitcoin_rpc_config(&self) -> BitcoinRpcConfig
fn get_bitcoin_rpc_config(&self) -> BitcoinRpcConfig
Returns the Bitcoin RPC config