Expand description
Docker-backed LND and Bitcoin Core regtest clusters for Rust integration tests.
The crate is library-first: integration tests should use the public API from here, while binaries and examples stay thin wrappers over the library.
§Example
use spawn_lnd::SpawnLnd;
let mut cluster = SpawnLnd::builder()
.nodes(["alice", "bob"])
.spawn()
.await?;
cluster.fund_nodes(["alice", "bob"]).await?;
let channel = cluster.open_channel("alice", "bob").await?;
let mut clients = cluster.connect_nodes().await?;
let alice_info = clients
.get_mut("alice")
.expect("alice client")
.lightning()
.get_info(lnd_grpc_rust::lnrpc::GetInfoRequest {})
.await?
.into_inner();
assert!(alice_info.synced_to_chain);
assert!(channel.from_channel.active);
cluster.shutdown().await?;Structs§
- Bitcoin
Core - A running Bitcoin Core container and its RPC handles.
- Bitcoin
Core Config - Configuration for one spawned Bitcoin Core regtest backend.
- Bitcoin
RpcAuth - RPC credentials for Bitcoin Core.
- Bitcoin
RpcClient - Minimal async JSON-RPC client for Bitcoin Core regtest nodes.
- Block
Info - Subset of Bitcoin Core
getblockresponse used by this crate. - Blockchain
Info - Subset of Bitcoin Core
getblockchaininfoused by this crate. - Channel
Report - Result of opening and confirming a public Lightning channel.
- Cleanup
Failure - Failure for one Docker resource cleanup operation.
- Cleanup
Report - Summary of a cleanup operation.
- Container
Spec - Docker container creation parameters used by
DockerClient. - Create
Wallet - Response from Bitcoin Core
createwallet. - Docker
Client - Thin async wrapper around a Bollard Docker client.
- Funding
Report - Result of funding an LND wallet.
- LndConfig
- Configuration for one spawned LND node.
- LndDaemon
- A running LND container and authenticated connection material.
- Load
Wallet - Response from Bitcoin Core
loadwallet. - Managed
Network - Metadata for a Docker network managed by this crate.
- Network
Spec - Docker network creation parameters used by
DockerClient. - Node
Config - Per-node LND configuration.
- Peer
Connection - Result of connecting one LND node to another.
- Retry
Policy - Retry parameters for startup and readiness polling.
- Spawn
Lnd - Entry point for building and spawning a cluster.
- Spawn
LndBuilder - Builder for
SpawnLndConfig. - Spawn
LndConfig - Complete cluster configuration.
- Spawned
Cluster - A running regtest cluster containing Bitcoin Core and LND containers.
- Spawned
Container - Metadata for a container created by this crate.
- Spawned
Node - A spawned LND node and its placement in the cluster.
- Startup
Rollback - Tracks containers that should be removed if startup fails.
Enums§
- Bitcoin
Core Error - Error returned while spawning or preparing Bitcoin Core.
- Bitcoin
RpcError - Error returned by the Bitcoin Core JSON-RPC client.
- Config
Error - Configuration validation error.
- Container
Role - Role label for a managed container.
- Docker
Error - Error returned by Docker operations.
- Image
Status - Result of ensuring an image is available locally.
- LndError
- Error returned by LND lifecycle and RPC helpers.
- Spawn
Error - Error returned by cluster lifecycle and orchestration operations.
Constants§
- BITCOIND_
P2P_ PORT - Regtest P2P port exposed by Bitcoin Core inside the Docker container.
- BITCOIND_
RPC_ PORT - Regtest RPC port exposed by Bitcoin Core inside the Docker container.
- DEFAULT_
BITCOIND_ IMAGE - Default Bitcoin Core Docker image used for new clusters.
- DEFAULT_
BITCOIN_ RPC_ USER - Default RPC user configured for spawned Bitcoin Core nodes.
- DEFAULT_
BITCOIN_ WALLET_ MATURITY_ BLOCKS - Number of blocks mined to mature the default wallet’s coinbase outputs.
- DEFAULT_
BITCOIN_ WALLET_ NAME - Default wallet name used for mining and funding operations.
- DEFAULT_
CHANNEL_ CAPACITY_ SAT - Default public channel capacity opened by
SpawnedCluster::open_channel. - DEFAULT_
CHANNEL_ CONFIRMATION_ BLOCKS - Default number of blocks mined after opening a channel.
- DEFAULT_
FUNDING_ AMOUNT_ BTC - Default on-chain funding amount sent to each LND node.
- DEFAULT_
FUNDING_ CONFIRMATION_ BLOCKS - Default number of blocks mined after funding transactions.
- DEFAULT_
GENERATE_ ADDRESS - Static regtest address used for internal block generation.
- DEFAULT_
LND_ IMAGE - Default LND Docker image used for new clusters.
- DEFAULT_
NODES_ PER_ BITCOIND - Default number of LND nodes assigned to each Bitcoin Core regtest backend.
- DEFAULT_
NODE_ ALIAS - Default node alias used when a builder is spawned without explicit nodes.
- DEFAULT_
STARTUP_ RETRY_ ATTEMPTS - Default retry count for Docker and daemon readiness polling.
- DEFAULT_
STARTUP_ RETRY_ INTERVAL_ MS - Default delay between readiness retry attempts.
- ENV_
BITCOIND_ IMAGE - Environment variable overriding the Bitcoin Core image.
- ENV_
CLUSTER_ SUBNET - Environment variable overriding the Docker network IPv4 subnet.
- ENV_
KEEP_ CONTAINERS - Environment variable preserving containers after failure or shutdown.
- ENV_
LND_ IMAGE - Environment variable overriding the LND image.
- ENV_
NODES_ PER_ BITCOIND - Environment variable overriding the number of LND nodes per Bitcoin Core.
- ENV_
STARTUP_ RETRY_ ATTEMPTS - Environment variable overriding readiness retry attempts.
- ENV_
STARTUP_ RETRY_ INTERVAL_ MS - Environment variable overriding readiness retry interval milliseconds.
- LABEL_
CLUSTER - Docker label key storing the generated cluster id.
- LABEL_
MANAGED - Docker label key marking containers managed by this crate.
- LABEL_
MANAGED_ VALUE - Docker label value used with
LABEL_MANAGED. - LABEL_
NODE - Docker label key storing an LND node alias when applicable.
- LABEL_
ROLE - Docker label key storing the managed container role.
- LND_
ADMIN_ MACAROON_ PATH - Path to the admin macaroon inside the LND container.
- LND_
GRPC_ PORT - LND gRPC port exposed inside the Docker container.
- LND_
P2P_ PORT - LND P2P port exposed inside the Docker container.
- LND_
TLS_ CERT_ PATH - Path to the TLS certificate inside the LND container.
- LND_
WALLET_ PASSWORD - Fixed wallet password used for spawned regtest LND nodes.
- VERSION
- Current crate version as declared by Cargo.
Functions§
- bitcoin_
core_ auth_ hmac - Compute Bitcoin Core’s HMAC-SHA256
rpcauthdigest. - bitcoin_
core_ rpcauth - Build the value for Bitcoin Core’s
-rpcauthflag. - cluster_
label_ filters - Build Docker list filters that match containers for a specific cluster.
- managed_
container_ labels - Build the Docker labels applied to every managed container.
- managed_
label_ filters - Build Docker list filters that match all containers managed by this crate.
- managed_
network_ labels - Build the Docker labels applied to every managed network.
- managed_
network_ name - Build the Docker network name for a cluster.