Lnd Emulator Utility · Simple
Mastering the Lightning Network: The Essential Guide to the LND Emulator Utility
Why a Dedicated Utility? (Use Cases)
Before the advent of robust emulation utilities, developers had two choices:
- Regtest (Regression Test): Spin up a private Bitcoin network with
btcd,lnd, andbitcoind. This works but is heavy (multiple containers, slow startup, disk I/O heavy). - Unit Tests with Mocks: Mock the LND client at the code level. This is fast but unrealistic—it misses cross-component interactions like HTLC timeouts and fee updates.
The LND emulator utility bridges this gap. Common use cases include: lnd emulator utility
CI Pipeline (GitHub Actions)
- name: Start LND Emulator
run: |
./lnd-emulator --port=10009 &
sleep 2
name: Run Integration Tests run: | go test -v ./... --lnd-host=localhost:10009
Core Components:
- gRPC Server (using
grpc-goorgrpc-node): Implement thelndprotobuf service. - In-Memory Store: Golang map or Redis for channels, invoices, and payments.
- State Machine: A simple HTLC simulator with timer goroutines.
- Fake Router: A graph of connected "peers" with channel capacities.
4.2. REST Dashboard (optional)
- Web UI to view channels, invoices, payments
- Manual payment trigger
- Force-close channels / fail HTLCs