spawn-lnd
spawn-lnd is a Rust library for spawning Docker-backed Bitcoin Core and LND
regtest nodes for integration tests.
The crate is library-first. It owns Docker lifecycle, daemon startup, wallet
initialization, credential extraction, and readiness checks, then returns
connection data that works with lnd_grpc_rust.
Status
Implemented:
- Docker connection and labeled container lifecycle.
- Pull-if-missing Docker images.
- Cleanup by cluster label and rollback for partial startup failures.
- Bitcoin Core regtest spawn and JSON-RPC client.
- LND spawn, TLS cert extraction, wallet init, admin macaroon extraction.
- LND readiness that requires authenticated
GetInfoandsynced_to_chain=true. - Multi-node cluster orchestration with one Bitcoin Core per three LNDs by default.
- Alias-keyed node metadata and
connect_nodes()integration withlnd_grpc_rust. - Lightning peer connection between aliases.
- Wallet funding through a primary Bitcoin Core wallet: mine mature coinbase
funds once, then use wallet RPC (
sendmanyfor batches) to fund LND wallets and mine one confirmation block. - Channel opening helpers that wait for pending state, mine confirmations, and wait for both sides to report the channel active.
- Configurable startup retry policy for slower Docker hosts and CI.
In progress:
- Minimal CLI.
Default Images
- Bitcoin Core:
lightninglabs/bitcoin-core:30 - LND:
lightninglabs/lnd:v0.20.1-beta
Example
use SpawnLnd;
async
Tests
Docker-backed tests require a local Docker Engine that can pull:
lightninglabs/bitcoin-core:30lightninglabs/lnd:v0.20.1-betahello-world:latest
Run normal unit and gated smoke tests without Docker:
Run Docker-backed smoke tests:
RUN_DOCKER_TESTS=1
RUN_DOCKER_TESTS=1
RUN_DOCKER_TESTS=1
RUN_DOCKER_TESTS=1
RUN_DOCKER_TESTS=1
RUN_DOCKER_TESTS=1
RUN_DOCKER_TESTS=1
Check for leftover managed containers:
Remove all managed containers:
Keep containers for debugging failed tests:
SPAWN_LND_KEEP_CONTAINERS=1 RUN_DOCKER_TESTS=1
Startup failures include a bounded Docker log tail in the typed error when a container was created before readiness failed.
Configuration
The builder supports node aliases, image overrides, chain grouping, debug cleanup behavior, and startup retry policy:
use ;
let config = builder
.nodes
.startup_retry_policy
.build?;
Environment overrides:
SPAWN_LND_BITCOIND_IMAGESPAWN_LND_LND_IMAGESPAWN_LND_NODES_PER_BITCOINDSPAWN_LND_KEEP_CONTAINERSSPAWN_LND_STARTUP_RETRY_ATTEMPTSSPAWN_LND_STARTUP_RETRY_INTERVAL_MS
Startup Flags
Bitcoin Core uses compose-style regtest flags:
-regtest-printtoconsole-rpcbind=0.0.0.0-rpcallowip=0.0.0.0/0-fallbackfee=0.00001-server-txindex-blockfilterindex-coinstatsindex-rpcuser=<generated>-rpcpassword=<generated>
LND uses:
--bitcoin.regtest--bitcoin.node=bitcoind--bitcoind.rpcpolling--bitcoind.rpchost=<bitcoind-bridge-ip>:18443--bitcoind.rpcuser=<generated>--bitcoind.rpcpass=<generated>--debuglevel=info--noseedbackup--listen=0.0.0.0:9735--rpclisten=0.0.0.0:10009