https://github.com/bitcoindevkit/bdk-bitcoind-client
Bitcoin Core RPC Client (experimental)
https://github.com/bitcoindevkit/bdk-bitcoind-client
Last synced: about 2 months ago
JSON representation
Bitcoin Core RPC Client (experimental)
- Host: GitHub
- URL: https://github.com/bitcoindevkit/bdk-bitcoind-client
- Owner: bitcoindevkit
- License: mit
- Created: 2025-11-12T16:37:27.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2026-02-11T22:04:26.000Z (4 months ago)
- Last Synced: 2026-02-12T06:06:53.875Z (4 months ago)
- Language: Rust
- Size: 65.4 KB
- Stars: 7
- Watchers: 4
- Forks: 5
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# bdk-bitcoind-client
A minimal Bitcoin Core RPC client designed specifically for the Bitcoin Dev Kit (BDK). It retrieves blockchain data from `bitcoind` over JSON-RPC and supports multiple versions of Bitcoin Core (v28.0 through v30.0+).
### Features
- _Version Pinning_: Explicit support for different Bitcoin Core RPC schemas via feature flags (28_0, 29_0, 30_0).
- _Minimal Dependencies_: Uses bitreq_http for a lightweight HTTP transport by default.
- _Wallet-Agnostic_: Focused on blockchain data emission (blocks, headers, mempool) rather than wallet management.
- _Robust Error Handling_: Specific error variants for RPC failures, deserialization issues, and transport timeouts.
### Installation
Add this to your `Cargo.toml`:
```toml
# For the latest Bitcoin Core (v30.0+)
bdk-bitcoind-client = { version = "0.1.0" }
# OR for older nodes (e.g., v28.x)
bdk-bitcoind-client = { version = "0.1.0", default-features = false, features = ["28_0"] }
```
### Quick Start
```rust
use bdk_bitcoind_client::{Auth, Client};
use std::path::PathBuf;
fn main() -> anyhow::Result<()> {
// 1. Setup authentication (Cookie file is recommended for security)
let auth = Auth::CookieFile(PathBuf::from("/path/to/regtest/.cookie"));
// 2. Initialize the client
let client = Client::with_auth("http://127.0.0.1:18443", auth)?;
// 3. Query the blockchain
let block_count = client.get_block_count()?;
let best_hash = client.get_block_hash(block_count)?;
// 4. Get verbose headers (handles schema differences automatically)
let header = client.get_block_header_verbose(&best_hash)?;
println!("Chain tip: {} at height {}", header.hash, header.height);
Ok(())
}
```
### Version Compatibility
Bitcoin Core often changes its JSON-RPC response fields (e.g., adding the target field in `v29/v30`). This client manages these differences through compile-time features.
| Feature | Bitcoin Core Version | Notes |
| ----------------- | --------------------- | -------------------------------------------- |
| 30_0 (default) | v30.x and newer | Supports latest target and difficulty fields.|
| 29_0 | v29.x | Aligned with v29 schema. |
| 28_0 | v28.x and older | Omits newer fields |
### Development and Testing
To run tests against a specific Bitcoin Core version, use the corresponding feature flag:
```
cargo test --no-default-features --features 28_0
```
### Minimum Supported Rust Version (MSRV)
The library maintain a MSRV of 1.85.0.
## Just
This project has a [`justfile`](/justfile) for easy command running. You must have [`just`](https://github.com/casey/just) installed.
To see a list of available recipes: `just`
## License
Licensed under either of
* Apache License, Version 2.0 ([Apache 2.0](LICENSE-APACHE) or )
* MIT License ([MIT](LICENSE-MIT) or )
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.