Generate bitcoin-rpc-midas, a Bitcoin Core client that supercharges Bitcoin testing and development.
Compared to hand-written RPC clients, midas offers:
- Reduced repetition
- Fewer versioning issues
- Increased compile-time checks
- Improved isolation from environment glitches
Together, these features translate Bitcoin Core into idiomatic Rust.
This project applies semantic compression. It models the RPC surface as a structured schema and generates type-safe Rust clients directly from that schema. This unites Rust consumers of the RPC interface layer. All generated code is derived from a single source of truth: bitcoin-core-api.json. By adopting this schema, consistency is guaranteed not only within this codebase, but also across any Rust project that consumes Core RPCs.
Deep Dive: docs/semantic-compression.md
See docs/architecture.mmd for a full system diagram.
The project is organized into several focused crates:
- types: Type definitions for Bitcoin Core's JSON-RPC interface
- conversions: For converting Bitcoin RPC types to Rust types
- codegen: Emits idiomatic Rust modules and clients
- pipeline: Coordinates end-to-end code generation
- transport: RPC transport and error handling
- node: Multi-node management and test client support
- config: Configuration utilities
All components are modular and reusable.
This asynchronous example uses Tokio and enables some
optional features, so your Cargo.toml
could look like this:
[dependencies]
bitcoin-rpc-midas = "29.1.2"
tokio = { version = "1.0", features = ["full"] }
And then the code:
use bitcoin_rpc_midas::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = BitcoinTestClient::new_with_network(Network::Regtest).await?;
let blockchain_info = client.getblockchaininfo().await?;
println!("Blockchain info:\n{blockchain_info:#?}");
Ok(())
}
Contributors are warmly welcome, see CONTRIBUTING.md.
MIT OR Apache-2.0
Part of the bitcoin-rpc crate ecosystem, providing type-safe Rust primitives for testing and development at the Bitcoin Core JSON-RPC interface.
This library communicates directly with bitcoind
. For mainnet use, restrict RPC access to trusted hosts and avoid exposing RPC endpoints to untrusted networks.