halfin
A {regtest} bitcoin node and indexer runner 🏃♂️
This crate makes it simple to run regtest bitcoind,
utreexod, electrs,
and electrumx instances from Rust code,
useful in integration test contexts.
Supported Implementations
| Kind | Implementation | Version | Feature Flag | Default Feature |
|---|---|---|---|---|
| Node | bitcoind |
v31.0 |
bitcoind |
Yes |
| Node | utreexod |
v0.6.0 |
utreexod |
Yes |
| Indexer | electrs |
v0.11.1 |
electrs |
No |
| Indexer | electrumx |
v1.20.0 |
electrumx |
No |
Binaries are downloaded automatically at build time: see build.rs.
BitcoinD
use connect;
use BitcoinD;
// Use a downloaded binary
let bitcoind_alpha = new.unwrap;
// Use a local binary
let bin_path = from_str.unwrap;
let bitcoind_beta = from_bin.unwrap;
// Connect peers
connect.unwrap
// Mine blocks
bitcoind_alpha.generate.unwrap;
assert_eq!;
// Wait for a node to catch up with the other
wait_for_height.unwrap;
assert_eq!;
ElectrsD
use BitcoinD;
use ElectrsD;
let bitcoind = new.unwrap;
bitcoind.generate.unwrap;
let electrs = new.unwrap;
electrs.wait_until_caught_up.unwrap;
UtreexoD
use UtreexoD;
// Use a downloaded binary
let utreexod = new.unwrap;
// Mine blocks
utreexod.generate.unwrap;
assert_eq!;
// Perform a raw RPC call
let res = utreexod.call.unwrap;
Developing
This project uses just for command running, and
cargo-rbmt
to manage everything related to cargo, such as formatting, linting, testing and CI. To install them, run:
~$ cargo install just
~$ cargo install cargo-rbmt
A justfile is provided for convenience. Run just to see available commands:
~$ just
> halfin
> A regtest runner for `bitcoind` and `utreexod`
Available recipes:
audit # Run `cargo audit` on all lockfiles and prune ignored advisories [alias: a]
build # Build `halfin` [alias: b]
check # Check code formatting, compilation, and linting [alias: c]
check-sigs # Checks whether all commits in this branch are signed [alias: cs]
doc # Generate documentation [alias: d]
doc-open # Generate and open documentation [alias: do]
fmt # Format code [alias: f]
lock # Regenerate Cargo-recent.lock and Cargo-minimal.lock [alias: l]
pre-push # Run pre-push checks [alias: p]
shellcheck # Run ShellCheck [alias: sc]
test # Run tests with relevant toolchain and lockfile combinations [alias: t]
toolchains # Install and/or Update `cargo-rbmt` and Stable and Nightly toolchains
zizmor # Run Zizmor Static Analysis [alias: z]
Minimum Supported Rust Version
This library should compile with any combination of features on Rust 1.85.0.
To build with the MSRV toolchain, copy Cargo-minimal.lock to Cargo.lock.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
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.