Welcome to the technical guide for the haveno-rust
Rust library. This crate provides low-level support for interacting with the Haveno network, focusing on initial peer bootstrapping, protobuf-based message creation, envelope serialization, and SOCKS5-based Tor transport.
The library is designed for projects needing to:
NetworkEnvelope
.Filter
messages for node advertisement..onion
services using tokio-socks
.src/
βββ lib.rs
βββ generated/ # Prost-generated protobuf structs
β βββ io/haveno/protobuffer/
β βββ network_envelope.rs
β βββ data_message.rs
β βββ storage.rs
β βββ ...
βββ messages/
β βββ filter.rs # Filter message creation and signing
β βββ ...
βββ utils/
β βββ network/
β β βββ envelope.rs # send_envelope / recv_envelope logic
β βββ crypto.rs # ed25519 + key parsing
βββ config/
βββ mod.rs # Loads base64 secret from JSON
Cargo.toml
[dependencies]
haveno = { git = "https://github.com/KewbitXMR/haveno-rust.git" }
tokio = { version = "1", features = ["full"] }
anyhow = "1"
Create a config.json
file:
{
"secret": "base64-encoded-ed25519-secret"
}
This secret will be used to sign all Filter
messages. You can generate a new one using:
openssl genpkey -algorithm Ed25519 -outform DER | base64
use haveno_basic_bootstrap::{
config::load_secret_key,
messages::filter::create_signed_filter,
utils::network::envelope::{build_envelope, send_envelope},
};
use tokio_socks::tcp::Socks5Stream;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
let secret_key = load_secret_key("config.json")?;
let filter_msg = create_signed_filter(secret_key)?;
let envelope = build_envelope(filter_msg);
let mut stream = Socks5Stream::connect("127.0.0.1:9050", "seednode.onion:2001").await?;
send_envelope(&mut stream, &envelope).await?;
println!("β
Filter message sent successfully");
Ok(())
}
use haveno_basic_bootstrap::utils::network::envelope::recv_envelope;
let received = recv_envelope(&mut stream).await?;
println!("π© Got envelope: {:#?}", received);
We include some basic integration tests under tests/
which simulate message signing and serialization.
cargo test --all
To test with an actual .onion
seed node, use a local Tor SOCKS5 proxy and point the stream to localhost:9050
.
Never share or commit your config.json
or secret keys to version control. It is your node's persistent identity on the Haveno network and must be safeguarded.
Function | Description |
---|---|
create_signed_filter(secret) |
Builds and signs a Filter protobuf message. |
build_envelope(msg) |
Wraps a protobuf Message into a NetworkEnvelope . |
send_envelope(stream, envelope) |
Sends envelope over async stream. |
recv_envelope(stream) |
Receives and parses an envelope. |
load_secret_key("config.json") |
Loads base64-encoded ed25519 key. |
Compatible with:
All protobuf message layouts follow the haveno-protobuffer definitions.
For help, visit the Haveno Community or open an issue on the GitHub repository.