A (legacy) Rust library for building Bitcoin SV applications and infrastructure, providing robust tools for P2P networking, address handling, transaction processing, and more.
** Note: Active development of Rust SV has now ceased. Active development continues upon Rust SV"s replacement, 💡Nour
- P2P Protocol: Construct and serialize messages for Bitcoin SV's peer-to-peer network.
- Address Handling: Encode/decode base58 addresses for P2PKH and P2SH (e.g.,
addr_encode,addr_decode). - Transaction Signing: Create and sign transactions with Bitcoin SV scripts.
- Script Evaluation: Execute and validate Bitcoin SV scripts.
- Node Connections: Establish connections to Bitcoin SV nodes with basic message handling.
- Wallet Support: Derive keys and parse mnemonics for wallet applications.
- Network Support: Full compatibility with Mainnet and Testnet, including Genesis upgrade.
- Primitives: Utilities for hashes (
Hash160,sha256d), and other Bitcoin SV primitives.
Add rust-sv to your Cargo.toml:
[dependencies]
sv = { git = "https://github.com/murphsicles/rust-sv", tag = "v0.5.2" }Or use the latest development version:
[dependencies]
sv = { git = "https://github.com/murphsicles/rust-sv", branch = "main" }- Rust: Stable (1.86 or later)
- Dependencies:
libzmq3-dev,libpq-dev(for projects likeRustBus) - OS: Linux, macOS, or Windows (Linux recommended for production)
Install dependencies on Ubuntu:
sudo apt-get update && sudo apt-get install -y libzmq3-devuse sv::address::{addr_encode, AddressType};
use sv::network::Network;
use sv::util::hash160;
let pubkeyhash = hash160(&[0; 33]);
let addr = addr_encode(&pubkeyhash, AddressType::P2PKH, Network::Mainnet);
println!("Address: {}", addr);use sv::address::addr_decode;
use sv::network::Network;
let addr = "15wpV72HRpAFPMmosR3jvGq7axU7t6ghX5";
let (pubkeyhash, addr_type) = addr_decode(&addr, Network::Mainnet).unwrap();
println!("Pubkey Hash: {:?}", pubkeyhash);
println!("Address Type: {:?}", addr_type);use sv::network::Network;
use sv::node::Node;
use async_std::net::TcpStream;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let stream = TcpStream::connect("127.0.0.1:8333").await?;
let mut node = Node::new(stream, Network::Mainnet, None)?;
let version = node.handshake().await?;
println!("Connected to node with version: {}", version);
Ok(())
}More examples are available in the examples directory.
Clone the repository and run tests:
git clone https://github.com/murphsicles/rust-sv.git
cd rust-sv
cargo test -- --nocaptureBuild the library:
cargo build --release- Consensus Code: This library is not currently suitable for consensus-critical applications due to incomplete validation checks. (Coming Soon)
- Performance: Some features (e.g., script evaluation) may require optimization for high-throughput use cases.
- ZMQ Dependency: Node connections may require a running Bitcoin SV node with ZMQ enabled.
- RustBus: The Legendary BSV Microservices Engine built with
rust-sv.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/my-feature). - Commit changes (
git commit -m "Add my feature"). - Push to the branch (
git push origin feature/my-feature). - Open a Pull Request.
Report issues at GitHub Issues.
rust-sv is licensed under the MIT License.
- Built for the BSV blockchain community by murphsicles.
- Inspired by Bitcoin SV's commitment to massive on-chain scaling.