Skip to main content

Crate bsv_rs

Crate bsv_rs 

Source
Expand description

§bsv-rs

A Rust SDK for BSV: cryptographic primitives, the Bitcoin Script interpreter, transactions with BEEF/SPV, BRC-42 wallets, BRC-103 mutual authentication, and the overlay network (SHIP/SLAP/STEAK), with storage, registry, key-value and identity clients on top. It is a reference-parity port of the TypeScript @bsv/sdk (cross-checked against the Go SDK), pinned by shared test vectors and the ts-stack conformance corpus, and it builds for wasm32-unknown-unknown (Cloudflare Workers, browsers).

The README (README.md) is the guide: every code block in it is a file under examples/ that CI compiles. Each module carries its own docs.

§Feature flags

default = ["primitives", "script"]. Opt in per module: transaction, wallet, messages, compat, totp, auth, overlay, storage, registry, kvstore, identity, socketio; full turns every module on. Transports and platforms: http (reqwest: ARC, WhatsOnChain, the HTTP wallet substrate, overlay hosts), websocket (a tokio-tungstenite auth transport, opt-in), wasm (the JS RNG, runtime-agnostic timers, js_sys::Date for wall-clock reads).

§Quick start

use bsv_rs::primitives::{sha256, PrivateKey};

let private_key = PrivateKey::random();
let public_key = private_key.public_key();
let digest = sha256(b"Hello, BSV!");
let signature = private_key.sign(&digest).unwrap();
assert!(public_key.verify(&digest, &signature));

Re-exports§

pub use error::Error;
pub use error::Result;
pub use primitives::from_hex;
pub use primitives::hash160;
pub use primitives::sha256;
pub use primitives::sha256d;
pub use primitives::to_hex;
pub use primitives::BigNumber;
pub use primitives::PrivateKey;
pub use primitives::PublicKey;
pub use primitives::Signature;
pub use primitives::SymmetricKey;
pub use script::Address;
pub use script::LockingScript;
pub use script::Script;
pub use script::ScriptChunk;
pub use script::UnlockingScript;

Modules§

error
Error types for the BSV SDK.
primitives
BSV Primitives
script
BSV Script