| Crates.io | electrum_streaming_client |
| lib.rs | electrum_streaming_client |
| version | 0.4.0 |
| created_at | 2025-05-02 12:38:32.194867+00 |
| updated_at | 2025-06-23 10:12:12.162605+00 |
| description | Experimental but sane electrum client by @evanlinjin. |
| homepage | |
| repository | https://github.com/bitcoindevkit/electrum_streaming_client |
| max_upload_size | |
| id | 1657626 |
| size | 171,629 |
A streaming, sans-IO Electrum client for asynchronous and blocking Rust applications.
This crate provides low-level primitives and high-level clients for communicating with Electrum
servers over JSON-RPC. It supports both asynchronous (futures/tokio) and blocking transport
models.
Read/Write traits.State] struct tracks pending requests and processes server messages.use electrum_streaming_client::{AsyncClient, AsyncBatchRequest, Event};
use tokio::net::TcpStream;
use futures::StreamExt;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let stream = TcpStream::connect("127.0.0.1:50001").await?;
let (reader, writer) = stream.into_split();
let (client, mut events, worker) = AsyncClient::new_tokio(reader, writer);
tokio::spawn(worker); // spawn the client worker task
let mut batch = AsyncBatchRequest::new();
let fut = batch.request(electrum_streaming_client::request::RelayFee);
client.send_batch(batch)?;
let relay_fee = fut.await?;
println!("Relay fee: {relay_fee:?}");
while let Some(event) = events.next().await {
println!("Event: {event:?}");
}
Ok(())
}
tokio: Enables [AsyncClient::new_tokio] for use with Tokio-compatible streams.MIT