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;pub use transaction::ChangeDistribution;pub use transaction::Transaction;pub use transaction::TransactionInput;pub use transaction::TransactionOutput;pub use wallet::CacheConfig;pub use wallet::CachedKeyDeriver;pub use wallet::Counterparty;pub use wallet::KeyDeriver;pub use wallet::KeyDeriverApi;pub use wallet::ProtoWallet;pub use wallet::Protocol;pub use wallet::SecurityLevel;pub use messages::decrypt;pub use messages::encrypt;pub use messages::sign;pub use messages::verify;pub use compat::Language;pub use compat::Mnemonic;pub use compat::WordCount;pub use totp::Algorithm as TotpAlgorithm;pub use totp::Totp;pub use totp::TotpOptions;pub use totp::TotpValidateOptions;pub use auth::install_app_event_listener;pub use auth::run_dispatch;pub use auth::AppEvent;pub use auth::SocketIoFrameSource;pub use auth::SocketIoSink;pub use auth::SocketIoTransport;pub use auth::AuthMessage;pub use auth::Certificate;pub use auth::MasterCertificate;pub use auth::MessageType;pub use auth::Peer;pub use auth::PeerOptions;pub use auth::PeerSession;pub use auth::RequestedCertificateSet;pub use auth::SessionManager;pub use auth::SimplifiedFetchTransport;pub use auth::Transport;pub use auth::VerifiableCertificate;pub use auth::WebSocketTransport;pub use auth::WebSocketTransportOptions;pub use overlay::LookupAnswer;pub use overlay::LookupQuestion;pub use overlay::LookupResolver;pub use overlay::NetworkPreset;pub use overlay::Steak;pub use overlay::TaggedBEEF;pub use overlay::TopicBroadcaster;pub use storage::get_hash_from_url;pub use storage::get_url_for_file;pub use storage::is_valid_url;pub use storage::DownloadResult;pub use storage::StorageDownloader;pub use storage::StorageUploader;pub use storage::UploadFileResult;pub use storage::UploadableFile;pub use registry::BasketDefinitionData;pub use registry::BasketQuery;pub use registry::BroadcastFailure;pub use registry::BroadcastSuccess;pub use registry::CertificateDefinitionData;pub use registry::CertificateFieldDescriptor;pub use registry::CertificateQuery;pub use registry::DefinitionData;pub use registry::DefinitionType;pub use registry::ProtocolDefinitionData;pub use registry::ProtocolQuery;pub use registry::RegisterDefinitionResult;pub use registry::RegistryClient;pub use registry::RegistryClientConfig;pub use registry::RegistryRecord;pub use registry::RevokeDefinitionResult;pub use registry::TokenData;pub use kvstore::GlobalKVStore;pub use kvstore::KVStoreConfig;pub use kvstore::KVStoreEntry;pub use kvstore::KVStoreGetOptions;pub use kvstore::KVStoreQuery;pub use kvstore::KVStoreRemoveOptions;pub use kvstore::KVStoreSetOptions;pub use kvstore::KVStoreToken;pub use kvstore::LocalKVStore;pub use identity::Contact;pub use identity::ContactsManager;pub use identity::ContactsManagerConfig;pub use identity::DisplayableIdentity;pub use identity::IdentityClient;pub use identity::IdentityClientConfig;pub use identity::IdentityQuery;pub use identity::KnownCertificateType;
Modules§
- auth
- Auth Module
- block
- Header, proof-of-work, chain-work and merkle primitives.
- compat
- BSV SDK Compatibility Module
- error
- Error types for the BSV SDK.
- identity
- Identity Module
- kvstore
- KVStore Module
- messages
- Messages Module
- overlay
- Overlay Tools Module
- primitives
- BSV Primitives
- registry
- Registry Module
- script
- BSV Script
- storage
- Storage Module
- totp
- TOTP Module
- transaction
- BSV Transaction
- wallet
- Wallet module for BSV SDK.