rust_mempool/api/
addresses.rs1use anyhow::Result;
2
3use crate::Utxo;
4
5impl crate::MempoolClient {
6 pub async fn get_address_utxo(&self, address: &str) -> Result<Vec<Utxo>> {
7 let url = format!("{}/address/{}/utxo", self.base_url, address);
8 let response = self.client.get(&url).send().await?.error_for_status()?;
9
10 Ok(response.json().await?)
11 }
12}
13
14#[cfg(test)]
15mod tests {
16 use bitcoin::Network;
17
18 use crate::client::MempoolClient;
19
20 #[tokio::test]
21 async fn test_get_address_utxo() {
22 let client = MempoolClient::new(Network::Bitcoin);
23
24 let utxos = client
25 .get_address_utxo("1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY")
26 .await
27 .unwrap();
28 println!("{:?}", utxos);
29 }
30}