1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! # rustywallet-electrum
//!
//! Electrum protocol client for Bitcoin balance checking and UTXO fetching.
//!
//! This crate provides an async client for communicating with Electrum servers,
//! allowing you to query blockchain data without rate limits.
//!
//! ## Features
//!
//! - **Balance checking** - Get confirmed and unconfirmed balance for any address
//! - **Batch queries** - Check multiple addresses efficiently in a single request
//! - **UTXO listing** - Get unspent outputs for transaction building
//! - **Transaction operations** - Get raw transactions and broadcast signed ones
//! - **TLS support** - Secure connections to Electrum servers
//! - **Certificate pinning** - Enhanced security with SSL certificate pinning
//! - **Server discovery** - DNS-based server discovery
//! - **Connection pooling** - Efficient connection management
//! - **Real-time subscriptions** - Address and header change notifications
//!
//! ## Quick Start
//!
//! ```no_run
//! use rustywallet_electrum::{ElectrumClient, ClientConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to a public Electrum server
//! let client = ElectrumClient::new("electrum.blockstream.info").await?;
//!
//! // Check server connection
//! let version = client.server_version().await?;
//! println!("Connected to: {}", version.server_software);
//!
//! // Get balance for an address
//! let balance = client.get_balance("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa").await?;
//! println!("Confirmed: {} sats", balance.confirmed);
//! println!("Unconfirmed: {} sats", balance.unconfirmed);
//!
//! // Batch check multiple addresses
//! let addresses = vec![
//! "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
//! "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy",
//! ];
//! let balances = client.get_balances(&addresses).await?;
//! for (addr, bal) in addresses.iter().zip(balances.iter()) {
//! println!("{}: {} sats", addr, bal.confirmed);
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Server Discovery
//!
//! ```no_run
//! use rustywallet_electrum::discovery::ServerDiscovery;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let discovery = ServerDiscovery::new();
//! let best = discovery.best_server().await?;
//! println!("Best server: {} ({}ms)", best.hostname, best.latency_ms.unwrap_or(0));
//! Ok(())
//! }
//! ```
//!
//! ## Connection Pooling
//!
//! ```no_run
//! use rustywallet_electrum::{ClientConfig, pool::{ConnectionPool, PoolConfig}};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = ClientConfig::ssl("electrum.blockstream.info");
//! let pool = ConnectionPool::new(config, PoolConfig::default());
//! pool.initialize().await?;
//!
//! let client = pool.acquire().await?;
//! let balance = client.get_balance("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa").await?;
//! // Connection automatically returned to pool when dropped
//! Ok(())
//! }
//! ```
//!
//! ## Address Support
//!
//! All Bitcoin address types are supported:
//! - P2PKH (1...)
//! - P2SH (3...)
//! - P2WPKH (bc1q...)
//! - P2WSH (bc1q... longer)
//! - P2TR (bc1p...)
//!
//! ## Public Servers
//!
//! Built-in list of public Electrum servers:
//! - `electrum.blockstream.info:50002` (SSL)
//! - `electrum1.bluewallet.io:443` (SSL)
//! - `bitcoin.aranguren.org:50002` (SSL)
//!
//! ## Custom Configuration
//!
//! ```no_run
//! use rustywallet_electrum::{ElectrumClient, ClientConfig};
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = ClientConfig::ssl("electrum.blockstream.info")
//! .with_port(50002)
//! .with_timeout(Duration::from_secs(60))
//! .with_retry(5, Duration::from_secs(2));
//!
//! let client = ElectrumClient::with_config(config).await?;
//! Ok(())
//! }
//! ```
// Re-exports
pub use ElectrumClient;
pub use ;
pub use ;
pub use ;
// New v0.2 re-exports
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;