Skip to main content

ProviderTrait

Trait ProviderTrait 

Source
pub trait ProviderTrait {
    // Required methods
    fn get_network(&self) -> &SimplicityNetwork;
    fn broadcast_transaction(
        &self,
        tx: &Transaction,
    ) -> Result<TxReceipt<'_>, ProviderError>;
    fn wait(&self, txid: &Txid) -> Result<(), ProviderError>;
    fn fetch_tip_height(&self) -> Result<u32, ProviderError>;
    fn fetch_tip_timestamp(&self) -> Result<u64, ProviderError>;
    fn fetch_transaction(
        &self,
        txid: &Txid,
    ) -> Result<Transaction, ProviderError>;
    fn fetch_address_utxos(
        &self,
        address: &Address,
    ) -> Result<Vec<UTXO>, ProviderError>;
    fn fetch_scripthash_utxos(
        &self,
        script: &Script,
    ) -> Result<Vec<UTXO>, ProviderError>;
    fn fetch_fee_estimates(&self) -> Result<HashMap<String, f64>, ProviderError>;

    // Provided method
    fn fetch_fee_rate(&self, target_blocks: u32) -> Result<f32, ProviderError> { ... }
}
Expand description

Baseline traits detailing required interaction methods between the SDK client and the underlying blockchain node or API.

Required Methods§

Source

fn get_network(&self) -> &SimplicityNetwork

Retrieves the network configured for this provider.

Source

fn broadcast_transaction( &self, tx: &Transaction, ) -> Result<TxReceipt<'_>, ProviderError>

Attempts to broadcast a fully compiled transaction to the configured backend.

§Errors

Returns a ProviderError if network transmission fails, or if the backend explicitly rejects the transaction.

Source

fn wait(&self, txid: &Txid) -> Result<(), ProviderError>

Blocks and repeatedly polls the network until the specified transaction receives its first confirmation.

§Errors

Returns a ProviderError if the network fails or the designated timeout elapses without confirmation.

Source

fn fetch_tip_height(&self) -> Result<u32, ProviderError>

Retrieves the current block height of the network tip.

§Errors

Returns a ProviderError if the backend request fails or the returned height cannot be parsed.

Source

fn fetch_tip_timestamp(&self) -> Result<u64, ProviderError>

Retrieves the block timestamp representing network consensus clock tip.

§Errors

Returns a ProviderError if the hash query, subsequent block query, or block parsing fails.

Source

fn fetch_transaction(&self, txid: &Txid) -> Result<Transaction, ProviderError>

Retrieves the serialized transaction payload given its hex transaction ID.

§Errors

Returns a ProviderError if the node fails to locate the transaction or serialization fails.

Source

fn fetch_address_utxos( &self, address: &Address, ) -> Result<Vec<UTXO>, ProviderError>

Fetches all active unspent transaction outputs correlated to a particular public Address.

§Errors

Returns a ProviderError if the backend request fails or if UTXO parsing fails.

Source

fn fetch_scripthash_utxos( &self, script: &Script, ) -> Result<Vec<UTXO>, ProviderError>

Fetches all active unspent transaction outputs correlated to a given custom Script mapping.

§Errors

Returns a ProviderError if the backend request fails or if UTXO parsing fails.

Source

fn fetch_fee_estimates(&self) -> Result<HashMap<String, f64>, ProviderError>

Fetches network fee estimation models based on varying target confirmation block delays.

§Errors

Returns a ProviderError if the REST request fails or the resulting mappings fail to parse cleanly.

Provided Methods§

Source

fn fetch_fee_rate(&self, target_blocks: u32) -> Result<f32, ProviderError>

Attempts to extract the specific fee rate (in sats/kvb) necessary for the transaction to be confirmed within target_blocks.

§Errors

Passes along ProviderError if fetch_fee_estimates fails.

Implementors§