Skip to content

Commit 1da987e

Browse files
tvpeterValuedMammal
authored andcommitted
docs: Update API documentation
- Add syntax highlighting for code blocks in README
1 parent 699fafc commit 1da987e

2 files changed

Lines changed: 20 additions & 22 deletions

File tree

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# bdk-bitcoind-client
22

3-
A minimal, experimental Bitcoin Core RPC client designed specifically for the Bitcoin Dev Kit (BDK). Unlike generic RPC wrappers,
4-
`bdk-bitcoind-client` focuses on high-performance data emission and strict type safety, with built-in support for multiple Bitcoin
5-
Core versions (v28.0 through v30.0+).
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+).
64

75
### Features
86

@@ -14,17 +12,17 @@ Core versions (v28.0 through v30.0+).
1412
### Installation
1513

1614
Add this to your `Cargo.toml`:
17-
```
18-
// For the latest Bitcoin Core (v30.0+)
15+
```toml
16+
# For the latest Bitcoin Core (v30.0+)
1917
bdk-bitcoind-client = { version = "0.1.0" }
2018

21-
// OR for older nodes (e.g., v28.x)
19+
# OR for older nodes (e.g., v28.x)
2220
bdk-bitcoind-client = { version = "0.1.0", default-features = false, features = ["28_0"] }
2321
```
2422

2523
### Quick Start
2624

27-
```
25+
```rust
2826
use bdk_bitcoind_client::{Auth, Client};
2927
use std::path::PathBuf;
3028
fn main() -> anyhow::Result<()> {
@@ -55,7 +53,7 @@ Bitcoin Core often changes its JSON-RPC response fields (e.g., adding the target
5553
| ----------------- | --------------------- | -------------------------------------------- |
5654
| 30_0 (default) | v30.x and newer | Supports latest target and difficulty fields.|
5755
| 29_0 | v29.x | Aligned with v29 schema. |
58-
| 28_0v | 28.x and older | Omits newer fields |
56+
| 28_0 | v28.x and older | Omits newer fields |
5957

6058

6159
### Development and Testing

src/client.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ pub struct Client {
6363
}
6464

6565
impl Client {
66-
/// Creates a client connection to a bitcoind JSON-RPC server with authentication
66+
/// Creates a client connection to a bitcoind JSON-RPC server with authentication.
6767
///
6868
/// Requires authentication via username/password or cookie file.
6969
/// For connections without authentication, use `with_transport` instead.
7070
///
7171
/// # Arguments
7272
///
7373
/// * `url` - URL of the RPC server
74-
/// * `auth` - authentication method (`UserPass` or `CookieFile`).
74+
/// * `auth` - authentication method (`UserPass` or `CookieFile`)
7575
///
7676
/// # Errors
7777
///
@@ -109,7 +109,7 @@ impl Client {
109109
}
110110
}
111111

112-
/// Calls the underlying RPC `method` with given `args` list
112+
/// Calls the underlying RPC `method` with the given `args`.
113113
///
114114
/// This is the generic function used by all specific RPC methods.
115115
pub fn call<T>(&self, method: &str, args: &[serde_json::Value]) -> Result<T, Error>
@@ -124,9 +124,9 @@ impl Client {
124124
}
125125
}
126126

127-
/// `Bitcoind` RPC methods implementation for `Client`
127+
/// `bitcoind` RPC methods implementation for `Client`.
128128
impl Client {
129-
/// Retrieves the raw block data for a given block hash (verbosity 0)
129+
/// Retrieves the raw block data for a given block hash (verbosity 0).
130130
///
131131
/// # Arguments
132132
///
@@ -140,7 +140,7 @@ impl Client {
140140
.and_then(|block_hex| deserialize_hex(&block_hex).map_err(Error::DecodeHex))
141141
}
142142

143-
/// Retrieves the hash of the tip of the best block chain.
143+
/// Retrieves the hash of the best chain's block.
144144
///
145145
/// # Returns
146146
///
@@ -150,7 +150,7 @@ impl Client {
150150
.and_then(|blockhash_hex| blockhash_hex.parse().map_err(Error::HexToArray))
151151
}
152152

153-
/// Retrieves the number of blocks in the longest chain
153+
/// Retrieves the number of blocks in the longest chain.
154154
///
155155
/// # Returns
156156
///
@@ -162,36 +162,36 @@ impl Client {
162162
.map_err(Error::TryFromInt)
163163
}
164164

165-
/// Retrieves the block hash at a given height
165+
/// Retrieves the [`BlockHash`] of the block at `height`.
166166
///
167167
/// # Arguments
168168
///
169169
/// * `height`: The block height
170170
///
171171
/// # Returns
172172
///
173-
/// The `BlockHash` for the given height
173+
/// The [`BlockHash`] of the block at `height`
174174
pub fn get_block_hash(&self, height: u32) -> Result<BlockHash, Error> {
175175
self.call::<String>("getblockhash", &[json!(height)])
176176
.and_then(|blockhash_hex| blockhash_hex.parse().map_err(Error::HexToArray))
177177
}
178178

179-
/// Retrieve the `basic` BIP 157 content filter for a particular block
179+
/// Retrieve the Compact Block Filter (BIP-0158) with type `basic` for the block given its `Blockhash`.
180180
///
181181
/// # Arguments
182182
///
183183
/// * `block_hash`: The hash of the block whose filter is requested
184184
///
185185
/// # Returns
186186
///
187-
/// The `GetBlockFilter` structure containing the filter data
187+
/// The `GetBlockFilter` structure containing the filter data for the block
188188
pub fn get_block_filter(&self, block_hash: &BlockHash) -> Result<GetBlockFilter, Error> {
189189
let block_filter: v30::GetBlockFilter =
190190
self.call("getblockfilter", &[json!(block_hash)])?;
191191
block_filter.into_model().map_err(Error::GetBlockFilter)
192192
}
193193

194-
/// Retrieves the raw block header for a given block hash.
194+
/// Retrieves the `Header` for a `Block` given its `BlockHash`.
195195
///
196196
/// # Arguments
197197
///
@@ -205,7 +205,7 @@ impl Client {
205205
.and_then(|header_hex: String| deserialize_hex(&header_hex).map_err(Error::DecodeHex))
206206
}
207207

208-
/// Retrieves the transaction IDs of all transactions currently in the mempool
208+
/// Retrieves the `Txid`s for all transactions in the mempool.
209209
///
210210
/// # Returns
211211
///
@@ -215,7 +215,7 @@ impl Client {
215215
.map(|txids| txids.0)
216216
}
217217

218-
/// Retrieves the raw transaction data for a given transaction ID
218+
/// Retrieves the raw transaction data for a given transaction ID.
219219
///
220220
/// # Arguments
221221
///

0 commit comments

Comments
 (0)