# ethos-bitcoind

[![License: CC0-1.0](https://img.shields.io/badge/license-CC0--1.0-blue)](LICENSE)
[![Docs.rs](https://img.shields.io/docsrs/ethos-bitcoind)](https://docs.rs/ethos-bitcoind)
[![crates.io](https://img.shields.io/crates/v/ethos-bitcoind)](https://crates.io/crates/ethos-bitcoind)

A type-safe Rust client for Bitcoin Core v30.2 RPCs.

## Why Use This?

This client aims to provide:
- Less repetitive boilerplate
- Easier upgrades across protocol versions
- Compile-time type checks for RPC requests/responses
- Managed integration testing (spawns protocol daemons as subprocesses, handles ports)

## Project Structure

- `client_trait/`: Rust traits for Bitcoin Core RPC endpoints
- `node/`: Node manager for process orchestration in integration environments
- `bitcoin_core_client/`: Utilities for driving integration tests against spawned local nodes
- `transport/`: Async transport layer with batching and error handling
- `types/`: Typed response structs and enums for all RPC methods

## Example

This async example (using [Tokio](https://tokio.rs)) demonstrates integration testing with a spawned node:

```toml
[dependencies]
ethos-bitcoind = "30.2.6"
tokio = { version = "1", features = ["full"] }
```

```rust
use std::sync::Arc;

use ethos_bitcoind::{BitcoinClient, DefaultTransport, NodeManager, BitcoinNodeManager};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut manager = BitcoinNodeManager::new()?;
    manager.start().await?;
    let client: Arc<DefaultTransport> = manager.create_transport().await?;

    let result = client.get_blockchain_info().await?;
    println!("Blockchain info: {:?}", result);

    manager.stop().await?;

    Ok(())
}
```

## Requirements
Requires a working `bitcoind` in `$PATH`.

## About
This crate is generated by [ethos](https://github.com/nervana21/ethos). Its code is kept synchronized with upstream protocol changes through code generation.

## License
Ethos is released under the terms of the CC0-1.0 license. See [LICENSE](LICENSE) for details.

## Security
This library launches Bitcoin Core daemons for local integration testing. For real network use, use strong network/firewall controls and carefully audit all dependencies.
