Skip to main content

electrum_client_netagnostic/
lib.rs

1//! This library provides an extendable Bitcoin-Electrum client that supports batch calls,
2//! notifications and multiple transport methods.
3//!
4//! By default this library is compiled with support for SSL servers using [`rustls`](https://docs.rs/rustls) and support for
5//! plaintext connections over a socks proxy, useful for Onion servers. Using different features,
6//! the SSL implementation can be removed or replaced with [`openssl`](https://docs.rs/openssl).
7//!
8//! WebSocket support (`ws://` and `wss://`) can be enabled with the `use-websocket` feature.
9//!
10//! A `minimal` configuration is also provided, which only includes the plaintext TCP client.
11//!
12//! # Example
13//!
14//! ```no_run
15//! use electrum_client::{Client, ElectrumApi};
16//!
17//! let mut client = Client::new("tcp://electrum.blockstream.info:50001")?;
18//! let response = client.server_features()?;
19//! # Ok::<(), electrum_client::Error>(())
20//! ```
21
22extern crate core;
23extern crate log;
24#[cfg(feature = "use-openssl")]
25extern crate openssl;
26#[cfg(all(
27    any(
28        feature = "default",
29        feature = "use-rustls",
30        feature = "use-rustls-ring"
31    ),
32    not(feature = "use-openssl")
33))]
34extern crate rustls;
35extern crate serde;
36extern crate serde_json;
37
38#[cfg(any(
39    feature = "default",
40    feature = "use-rustls",
41    feature = "use-rustls-ring"
42))]
43extern crate webpki_roots;
44
45#[cfg(any(feature = "default", feature = "proxy"))]
46extern crate byteorder;
47
48#[cfg(all(unix, any(feature = "default", feature = "proxy")))]
49extern crate libc;
50#[cfg(all(windows, any(feature = "default", feature = "proxy")))]
51extern crate winapi;
52
53#[cfg(any(feature = "default", feature = "proxy"))]
54pub mod socks;
55
56#[cfg(feature = "use-websocket")]
57pub mod websocket;
58
59mod api;
60mod batch;
61
62#[cfg(any(
63    all(feature = "proxy", feature = "use-openssl"),
64    all(feature = "proxy", feature = "use-rustls"),
65    all(feature = "proxy", feature = "use-rustls-ring")
66))]
67pub mod client;
68
69mod config;
70
71pub mod raw_client;
72mod stream;
73mod types;
74
75pub use api::ElectrumApi;
76pub use batch::Batch;
77#[cfg(any(
78    all(feature = "proxy", feature = "use-openssl"),
79    all(feature = "proxy", feature = "use-rustls"),
80    all(feature = "proxy", feature = "use-rustls-ring")
81))]
82pub use client::*;
83pub use config::{Config, ConfigBuilder, Socks5Config};
84pub use types::*;