rust-electrum-client/examples/tor.rs
Riccardo Casatta 561db261d3
timeout() and socks() don't return Result
The `Result` was necessary in the past because they couldn't both be set,
this is not true anymore after 7493630ed8
2022-09-13 09:27:03 +02:00

24 lines
813 B
Rust

extern crate electrum_client;
use electrum_client::{Client, ConfigBuilder, ElectrumApi, Socks5Config};
fn main() {
// NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
// localhost:9050
let proxy = Socks5Config::new("127.0.0.1:9050");
let config = ConfigBuilder::new().socks5(Some(proxy)).build();
let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
let res = client.server_features();
println!("{:#?}", res);
// works both with onion v2/v3 (if your Tor supports them)
let client = Client::from_config(
"tcp://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion:110",
config,
)
.unwrap();
let res = client.server_features();
println!("{:#?}", res);
}