waterfalls-client
Waterfalls API client library. Supports plaintext, TLS and Onion servers. Blocking or async.
Overview
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.
Features
- Blocking and Async clients - Choose the right client for your use case
- Waterfalls API support - Query with descriptors or addresses
- Compatible endpoints - Transaction retrieval, block headers, broadcasting
- Proxy support - SOCKS proxy support for privacy
- TLS/SSL support - Secure connections with multiple TLS backends
- Retry logic - Automatic retries for temporary failures
Usage
Creating a Client
use Builder;
// Blocking client
let builder = new;
let blocking_client = builder.build_blocking;
// Async client
let builder = new;
let async_client = builder.build_async?;
Querying with Descriptors
// Query with a Bitcoin descriptor
let descriptor = "wpkh(xpub.../*)";
let response = client.waterfalls.await?;
// Query with specific parameters
let response = client.waterfalls_version.await?;
Querying with Addresses
use Address;
let addresses = vec!;
let response = client.waterfalls_addresses.await?;
Compatible Endpoints
// Get transaction
let tx = client.get_tx.await?;
// Get block header
let header = client.get_header_by_hash.await?;
// Get tip hash
let tip = client.get_tip_hash.await?;
// Broadcast transaction
client.broadcast.await?;
Testing
The library includes comprehensive unit and integration tests.
Unit Tests
Run the unit tests (no external dependencies required):
Simple Integration Tests
Basic integration tests that don't require external dependencies:
These verify client construction, error handling, and API signatures.
Full Integration Tests
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:
- Environment variables
BITCOIND_EXECandELEMENTSD_EXECare automatically set in the nix environment
Run integration tests:
The integration tests cover:
- All waterfalls-specific endpoints (
waterfalls,waterfalls_addresses, etc.) - Compatible Esplora endpoints (
get_tx,get_header_by_hash, etc.) - Server information endpoints (
server_recipient,server_address) - Both blocking and async clients
- Type conversions from waterfalls::be types to bitcoin types
Development
This project uses Nix for reproducible development environments: