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
impl MempoolClient
Sourcepub fn with_base_url(base_url: &str) -> Self
pub fn with_base_url(base_url: &str) -> Self
Create a new client with custom base URL.
Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Get the HTTP client (for internal use by extension modules).
Sourcepub async fn get_fees(&self) -> Result<FeeEstimates>
pub async fn get_fees(&self) -> Result<FeeEstimates>
Get recommended fee estimates.
Returns fee rates in sat/vB for different confirmation targets.
Sourcepub async fn get_address(&self, address: &str) -> Result<AddressInfo>
pub async fn get_address(&self, address: &str) -> Result<AddressInfo>
Get address information including balance and transaction count.
Sourcepub async fn get_address_txs(&self, address: &str) -> Result<Vec<Transaction>>
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.
Sourcepub async fn get_tx(&self, txid: &str) -> Result<Transaction>
pub async fn get_tx(&self, txid: &str) -> Result<Transaction>
Get transaction details by txid.
Sourcepub async fn get_tx_hex(&self, txid: &str) -> Result<String>
pub async fn get_tx_hex(&self, txid: &str) -> Result<String>
Get raw transaction hex by txid.
Sourcepub async fn get_block_height(&self) -> Result<u64>
pub async fn get_block_height(&self) -> Result<u64>
Get current block height.
Sourcepub async fn get_block_hash(&self, height: u64) -> Result<String>
pub async fn get_block_hash(&self, height: u64) -> Result<String>
Get block hash by height.
Source§impl MempoolClient
Lightning client extension for MempoolClient.
impl MempoolClient
Lightning client extension for MempoolClient.
Sourcepub async fn get_lightning_stats(&self) -> Result<LightningStats>
pub async fn get_lightning_stats(&self) -> Result<LightningStats>
Get Lightning Network statistics.
Sourcepub async fn get_top_nodes_by_capacity(
&self,
limit: Option<u32>,
) -> Result<Vec<LightningNode>>
pub async fn get_top_nodes_by_capacity( &self, limit: Option<u32>, ) -> Result<Vec<LightningNode>>
Get top Lightning nodes by capacity.
Sourcepub async fn get_lightning_node(&self, pubkey: &str) -> Result<LightningNode>
pub async fn get_lightning_node(&self, pubkey: &str) -> Result<LightningNode>
Get Lightning node by public key.
Sourcepub async fn get_node_channels(
&self,
pubkey: &str,
) -> Result<Vec<LightningChannel>>
pub async fn get_node_channels( &self, pubkey: &str, ) -> Result<Vec<LightningChannel>>
Get channels for a Lightning node.
Sourcepub async fn get_lightning_channel(
&self,
channel_id: &str,
) -> Result<LightningChannel>
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.
impl MempoolClient
Mining client extension for MempoolClient.
Sourcepub async fn get_hashrate_distribution(
&self,
period: &str,
) -> Result<HashrateDistribution>
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”
Sourcepub async fn get_difficulty_adjustment(&self) -> Result<DifficultyAdjustment>
pub async fn get_difficulty_adjustment(&self) -> Result<DifficultyAdjustment>
Get difficulty adjustment information.
Sourcepub async fn get_mining_pool(&self, slug: &str) -> Result<MiningPoolStats>
pub async fn get_mining_pool(&self, slug: &str) -> Result<MiningPoolStats>
Get mining pool information by slug.
Sourcepub async fn get_pool_blocks(
&self,
slug: &str,
block_height: Option<u64>,
) -> Result<Vec<PoolBlock>>
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
Sourcepub async fn get_block_rewards(&self, period: &str) -> Result<BlockRewardStats>
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”