pub trait IServerBitcoinRpc:
Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn get_bitcoin_rpc_config(&self) -> BitcoinRpcConfig;
fn get_url(&self) -> SafeUrl;
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_feerate<'life0, 'async_trait>(
&'life0 self,
) -> 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_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;
// Provided method
fn into_dyn(self) -> DynServerBitcoinRpc
where Self: Sized { ... }
}
Required Methods§
Sourcefn get_bitcoin_rpc_config(&self) -> BitcoinRpcConfig
fn get_bitcoin_rpc_config(&self) -> BitcoinRpcConfig
Returns the Bitcoin RPC config
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.
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,
Sourcefn get_feerate<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<Feerate>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_feerate<'life0, 'async_trait>(
&'life0 self,
) -> 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_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_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.