Crates.io | waterfalls-client |
lib.rs | waterfalls-client |
version | 0.2.0 |
created_at | 2025-09-02 06:24:30.29911+00 |
updated_at | 2025-09-02 17:11:31.893197+00 |
description | Waterfalls API client library. Supports plaintext, TLS and Onion servers. Blocking or async |
homepage | https://github.com/RCasatta/waterfalls-client |
repository | https://github.com/RCasatta/waterfalls-client |
max_upload_size | |
id | 1820654 |
size | 174,863 |
Waterfalls API client library. Supports plaintext, TLS and Onion servers. Blocking or async.
This library provides both blocking and asynchronous HTTP clients for interacting with Waterfalls servers. It supports querying transaction histories, UTXO data, and blockchain information using Bitcoin descriptors or addresses.
use waterfalls_client::Builder;
// Blocking client
let builder = Builder::new("https://waterfalls.example.com/api");
let blocking_client = builder.build_blocking();
// Async client
let builder = Builder::new("https://waterfalls.example.com/api");
let async_client = builder.build_async()?;
// Query with a Bitcoin descriptor
let descriptor = "wpkh(xpub.../*)";
let response = client.waterfalls(descriptor).await?;
// Query with specific parameters
let response = client.waterfalls_version(descriptor, 2, None, None, false).await?;
use bitcoin::Address;
let addresses = vec![address1, address2];
let response = client.waterfalls_addresses(&addresses).await?;
// Get transaction
let tx = client.get_tx(&txid).await?;
// Get block header
let header = client.get_header_by_hash(&block_hash).await?;
// Get tip hash
let tip = client.get_tip_hash().await?;
// Broadcast transaction
client.broadcast(&transaction).await?;
The library includes comprehensive unit and integration tests.
Run the unit tests (no external dependencies required):
nix develop -c cargo test --lib
Basic integration tests that don't require external dependencies:
nix develop -c cargo test --test simple_integration
These verify client construction, error handling, and API signatures.
Note: Uses waterfalls 0.9.4+ with type conversions between waterfalls::be and bitcoin types.
Integration tests require a running Waterfalls server with bitcoind. The tests use the waterfalls
crate's test_env
feature to automatically set up test environments.
Prerequisites:
BITCOIND_EXEC
and ELEMENTSD_EXEC
are automatically set in the nix environmentRun integration tests:
nix develop -c cargo test --test integration
The integration tests cover:
waterfalls
, waterfalls_addresses
, etc.)get_tx
, get_header_by_hash
, etc.)server_recipient
, server_address
)This project uses Nix for reproducible development environments:
nix develop # Enter development shell
cargo check # Check compilation
cargo test # Run tests