MempoolClient

Struct MempoolClient 

Source
pub struct MempoolClient { /* private fields */ }
Expand description

Mempool.space API client.

Provides methods for querying fee estimates, address information, transactions, and broadcasting.

§Example

use rustywallet_mempool::MempoolClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = MempoolClient::new();
     
    // Get fee estimates
    let fees = client.get_fees().await?;
    println!("Next block fee: {} sat/vB", fees.fastest_fee);
     
    // Get address info
    let info = client.get_address("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa").await?;
    println!("Balance: {} sats", info.confirmed_balance());
     
    Ok(())
}

Implementations§

Source§

impl MempoolClient

Source

pub fn new() -> Self

Create a new client for mainnet.

Source

pub fn testnet() -> Self

Create a new client for testnet.

Source

pub fn signet() -> Self

Create a new client for signet.

Source

pub fn with_base_url(base_url: &str) -> Self

Create a new client with custom base URL.

Source

pub fn base_url(&self) -> &str

Get the base URL.

Source

pub fn http_client(&self) -> &Client

Get the HTTP client (for internal use by extension modules).

Source

pub async fn get_fees(&self) -> Result<FeeEstimates>

Get recommended fee estimates.

Returns fee rates in sat/vB for different confirmation targets.

Source

pub async fn get_address(&self, address: &str) -> Result<AddressInfo>

Get address information including balance and transaction count.

Source

pub async fn get_utxos(&self, address: &str) -> Result<Vec<Utxo>>

Get UTXOs for an address.

Source

pub async fn get_address_txs(&self, address: &str) -> Result<Vec<Transaction>>

Get transaction history for an address.

Returns up to 50 most recent transactions.

Source

pub async fn get_tx(&self, txid: &str) -> Result<Transaction>

Get transaction details by txid.

Source

pub async fn get_tx_hex(&self, txid: &str) -> Result<String>

Get raw transaction hex by txid.

Source

pub async fn broadcast(&self, hex: &str) -> Result<String>

Broadcast a signed transaction.

§Arguments
  • hex - Raw transaction in hex format
§Returns
  • Transaction ID on success
Source

pub async fn get_block_height(&self) -> Result<u64>

Get current block height.

Source

pub async fn get_block_hash(&self, height: u64) -> Result<String>

Get block hash by height.

Source

pub async fn get_block(&self, hash: &str) -> Result<BlockInfo>

Get block information by hash.

Source§

impl MempoolClient

Lightning client extension for MempoolClient.

Source

pub async fn get_lightning_stats(&self) -> Result<LightningStats>

Get Lightning Network statistics.

Source

pub async fn get_top_nodes_by_capacity( &self, limit: Option<u32>, ) -> Result<Vec<LightningNode>>

Get top Lightning nodes by capacity.

Source

pub async fn get_lightning_node(&self, pubkey: &str) -> Result<LightningNode>

Get Lightning node by public key.

Source

pub async fn get_node_channels( &self, pubkey: &str, ) -> Result<Vec<LightningChannel>>

Get channels for a Lightning node.

Source

pub async fn get_lightning_channel( &self, channel_id: &str, ) -> Result<LightningChannel>

Get Lightning channel by ID.

Source§

impl MempoolClient

Mining client extension for MempoolClient.

Source

pub async fn get_hashrate_distribution( &self, period: &str, ) -> Result<HashrateDistribution>

Get hashrate distribution across mining pools.

§Arguments
  • period - Time period: “24h”, “3d”, “1w”, “1m”, “3m”, “6m”, “1y”, “2y”, “3y”, “all”
Source

pub async fn get_difficulty_adjustment(&self) -> Result<DifficultyAdjustment>

Get difficulty adjustment information.

Source

pub async fn get_mining_pool(&self, slug: &str) -> Result<MiningPoolStats>

Get mining pool information by slug.

Source

pub async fn get_pool_blocks( &self, slug: &str, block_height: Option<u64>, ) -> Result<Vec<PoolBlock>>

Get blocks mined by a pool.

§Arguments
  • slug - Pool slug (e.g., “foundryusa”, “antpool”)
  • block_height - Optional starting block height
Source

pub async fn get_block_rewards(&self, period: &str) -> Result<BlockRewardStats>

Get block reward statistics.

§Arguments
  • period - Time period: “24h”, “3d”, “1w”, “1m”, “3m”, “6m”, “1y”, “2y”, “3y”, “all”

Trait Implementations§

Source§

impl Default for MempoolClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more