Skip to content

Commit b8aef56

Browse files
committed
chore(doc): update README
Updates the README with pointers to `cargo-rbmt` and new recipes. Also adds badges and fixes a bunch of nits.
1 parent a37833e commit b8aef56

File tree

1 file changed

+84
-34
lines changed

1 file changed

+84
-34
lines changed

README.md

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,127 @@
11
# bdk-bitcoind-client
22

3-
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+).
3+
<p>
4+
<!-- <a href="https://crates.io/crates/bdk-bitcoind-client"><img src="https://img.shields.io/crates/v/bdk-bitcoind-client.svg"/></a> -->
5+
<!-- <a href="https://docs.rs/bdk-bitcoind-client"><img src="https://img.shields.io/badge/docs.rs-bdk-bitcoind-client-orange"/></a> -->
6+
<a href="https://blog.rust-lang.org/2025/02/20/Rust-1.85.0/"><img src="https://img.shields.io/badge/rustc-1.85.0%2B-orange.svg"/></a>
7+
<a href="https://github.com/bitcoindevkit/bdk-bitcoind-client/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT%2FApache--2.0-red.svg"/></a>
8+
<a href="https://github.com/bitcoindevkit/bdk-bitcoind-client/actions/workflows/cont_integration.yml"><img src="https://github.com/bitcoindevkit/bdk-bitcoind-client/actions/workflows/cont_integration.yml/badge.svg"></a>
9+
</p>
410

5-
### Features
11+
A minimal `bitcoind` RPC client custom built for [BDK](https://github.com/bitcoindevkit/bdk).
612

7-
- _Version Pinning_: Explicit support for different Bitcoin Core RPC schemas via feature flags (28_0, 29_0, 30_0).
8-
- _Minimal Dependencies_: Uses bitreq_http for a lightweight HTTP transport by default.
9-
- _Wallet-Agnostic_: Focused on blockchain data emission (blocks, headers, mempool) rather than wallet management.
10-
- _Robust Error Handling_: Specific error variants for RPC failures, deserialization issues, and transport timeouts.
13+
## Features
1114

12-
### Installation
15+
- **Multiple Bitcoin Core Version Support**: implements support for multiple Bitcoin Core versions in the backend:
16+
- Bitcoin Core v30.0
17+
- Bitcoin Core v29.0
18+
- Bitcoin Core v28.0
19+
20+
- **Minimal Dependencies**: by default, the minimal `bitreq_http` is used as the HTTP transport.
21+
22+
- **Separation of Concerns**: focused on emitting generic data structures, such as blocks,
23+
headers and mempool. Interpreting this data is left to wallets that use this crate as a chain-source.
24+
25+
- **Robust Error Handling**: implements specifc error variants for RPC, deserialization and transport errors.
26+
27+
## Usage
28+
29+
Add this to your `Cargo.toml` manifest to use this crate with
30+
the latest Bitcoin Core version (currently v30.0) as the backend:
1331

14-
Add this to your `Cargo.toml`:
1532
```toml
16-
# For the latest Bitcoin Core (v30.0+)
1733
bdk-bitcoind-client = { version = "0.1.0" }
34+
```
1835

19-
# OR for older nodes (e.g., v28.x)
36+
Alternatively, add this to your `Cargo.toml` manifest to use this crate
37+
with a specific Bitcoin Core version as the backend (v28.0 or v29.0):
38+
39+
```toml
40+
# Bitcoin Core v29.0
41+
bdk-bitcoind-client = { version = "0.1.0", default-features = false, features = ["29_0"] }
42+
43+
# Bitcoin Core v28.0
2044
bdk-bitcoind-client = { version = "0.1.0", default-features = false, features = ["28_0"] }
2145
```
2246

23-
### Quick Start
47+
## Quick Start
2448

2549
```rust
2650
use bdk_bitcoind_client::{Auth, Client};
2751
use std::path::PathBuf;
2852
fn main() -> anyhow::Result<()> {
29-
// 1. Setup authentication (Cookie file is recommended for security)
53+
// Define how to authenticate with `bitcoind` (Cookie File or User/Pass)
3054
let auth = Auth::CookieFile(PathBuf::from("/path/to/regtest/.cookie"));
55+
let auth = Auth::UserPass("user".to_string(), "pass".to_string());
3156

32-
// 2. Initialize the client
57+
// Instantiate a JSON-RCP `Client`
3358
let client = Client::with_auth("http://127.0.0.1:18443", auth)?;
3459

35-
// 3. Query the blockchain
60+
// Perform blockchain queries to `bitcoind` using the `Client`
3661
let block_count = client.get_block_count()?;
3762
let best_hash = client.get_block_hash(block_count)?;
38-
39-
// 4. Get verbose headers (handles schema differences automatically)
4063
let header = client.get_block_header_verbose(&best_hash)?;
41-
64+
65+
println!("Block Count: {}", block_count);
66+
println!("Best Block Hash: {}", best_hash);
4267
println!("Chain tip: {} at height {}", header.hash, header.height);
4368

4469
Ok(())
4570
}
4671
```
4772

48-
### Version Compatibility
73+
## Bitcoin Core Version Compatibility
4974

50-
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.
75+
Bitcoin Core often changes its JSON-RPC schema, such as the addition of the `target`
76+
and `difficulty` fields in the `getmininginfo` RPC on Bitcoin Core v29.0 and newer.
5177

52-
| Feature | Bitcoin Core Version | Notes |
53-
| ----------------- | --------------------- | -------------------------------------------- |
54-
| 30_0 (default) | v30.x and newer | Supports latest target and difficulty fields.|
55-
| 29_0 | v29.x | Aligned with v29 schema. |
56-
| 28_0 | v28.x and older | Omits newer fields |
78+
This crate manages this via compile-time feature flags:
5779

80+
| Feature Flag | Bitcoin Core Version | Notes |
81+
| ---------------- | -------------------- | ------------------------------------------------------------ |
82+
| `30_0` (default) | v30.x | |
83+
| `29_0` | v29.x | Supports `target` and `difficulty` fields on `getmininginfo` |
84+
| `28_0` | v28.x and older | Omits newer fields |
5885

59-
### Development and Testing
60-
To run tests against a specific Bitcoin Core version, use the corresponding feature flag:
6186

62-
```
63-
cargo test --no-default-features --features 28_0
64-
```
87+
## Developing
6588

66-
### Minimum Supported Rust Version (MSRV)
89+
This project uses [`cargo-rbmt`](https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools/tree/master/cargo-rbmt)
90+
to manage everything related to `cargo`, such as formatting, linting, testing and CI. To install it, run:
6791

68-
The library maintain a MSRV of 1.85.0.
92+
```console
93+
~$ cargo install cargo-rbmt
94+
```
95+
96+
A `justfile` is provided for convenient command-running. You must have
97+
[`just`](https://github.com/casey/just?tab=readme-ov-file#installation) installed.
98+
99+
Run `just` to see available commands:
100+
101+
```console
102+
> bdk-bitcoind-client
103+
> An experimental `bitcoind` RPC client for BDK
104+
105+
Available recipes:
106+
build # Build the `bdk-bitcoind-client` [alias: b]
107+
check # Check code formatting, compilation, and linting [alias: c]
108+
check-features # Check that all feature combinations compile [alias: cf]
109+
check-sigs # Checks whether all commits in this branch are PGP-signed [alias: cs]
110+
doc # Generate documentation [alias: d]
111+
doc-open # Generate and open documetation [alias: do]
112+
fmt # Format code [alias: f]
113+
lock # Regenerate `Cargo-recent.lock` and `Cargo-minimal.lock` [alias: l]
114+
msrv # Verify the library builds with the MSRV toolchain (1.85.0) [alias: m]
115+
pre-push # Run pre-push suite: lock, check-sigs, fmt, check, test, and msrv [alias: p]
116+
test # Run all tests on the workspace with all features [alias: t]
117+
test-version VERSION # Run tests against a specific Bitcoin Core version: 30_0, 29_0, 28_0 [alias: tv]
118+
```
69119

70-
## Just
120+
## Minimum Supported Rust Version (MSRV)
71121

72-
This project has a [`justfile`](/justfile) for easy command running. You must have [`just`](https://github.com/casey/just) installed.
122+
This library should compile with any combination of features on Rust 1.85.0.
73123

74-
To see a list of available recipes: `just`
124+
To build with the MSRV toolchain, copy `Cargo-minimal.lock` to `Cargo.lock`.
75125

76126
## License
77127

0 commit comments

Comments
 (0)