rustywallet-checker
A fast, reliable Rust library for checking cryptocurrency wallet balances. Supports Bitcoin and Ethereum with automatic fallback between multiple API providers.
Features
- Bitcoin Balance Checking: Support for all address types (Legacy, SegWit, Taproot)
- Ethereum Balance Checking: Native ETH balance queries
- Async/Await Support: Built with Tokio for high-performance async operations
- Multiple API Providers: Automatic fallback between providers for reliability
- Rate Limit Handling: Built-in retry logic and rate limit detection
- Comprehensive Error Handling: Detailed error types for different failure scenarios
- Zero-Copy Parsing: Efficient JSON parsing with minimal allocations
- Type Safety: Strong typing for addresses and balance amounts
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick Start
use ;
async
Bitcoin Balance Checking
Supported Address Types
- Legacy (P2PKH): Addresses starting with
1 - SegWit (P2WPKH): Addresses starting with
bc1q - Taproot (P2TR): Addresses starting with
bc1p
Example
use ;
async
API Providers
- Primary: blockstream.info API
- Fallback: blockchain.info API
Ethereum Balance Checking
Example
use ;
async
API Providers
Multiple public Ethereum RPC endpoints with automatic failover:
- Cloudflare ETH Gateway
- Ankr Public RPC
- Public Node RPC
Async Usage
All functions are async and return Futures. Use with any async runtime:
use check_btc_balance;
use tokio;
// With Tokio
async
// With async-std
use task;
Error Handling
The library provides comprehensive error handling with the CheckerError enum:
use ;
match check_btc_balance.await
Error Types
InvalidAddress: The provided address format is invalidRateLimited: API rate limit exceededNetworkError: Network connectivity issuesApiError: API provider returned an errorParseError: Failed to parse API response
API Reference
Functions
check_btc_balance(address: &str) -> Result<BtcBalance, CheckerError>
Checks the balance of a Bitcoin address.
Parameters:
address: Bitcoin address string (Legacy, SegWit, or Taproot)
Returns:
Ok(BtcBalance): Balance informationErr(CheckerError): Error details
check_eth_balance(address: &str) -> Result<EthBalance, CheckerError>
Checks the balance of an Ethereum address.
Parameters:
address: Ethereum address string (0x prefixed)
Returns:
Ok(EthBalance): Balance informationErr(CheckerError): Error details
Types
BtcBalance
EthBalance
CheckerError
License
This project is licensed under the MIT License - see the LICENSE file for details.