A comprehensive guide for setting up and using the CDK regtest environment for development and testing.
# Start regtest with SQLite database (default)
just regtest
# Or with REDB database
just regtest redb
The script will:
mprocs and offer to install it if missingmprocs TUI showing all component logsPress q in mprocs or Ctrl+C in the terminal. Everything cleans up automatically.
When running, you get a complete Lightning Network environment:
127.0.0.1:18443 (user: testuser, pass: testpass)$CDK_ITESTS_DIR/cln/one/regtest/lightning-rpc$CDK_ITESTS_DIR/cln/two/regtest/lightning-rpchttps://localhost:10009https://localhost:10010http://127.0.0.1:8085 (connected to CLN node 1)http://127.0.0.1:8087 (connected to LND node 2)Available in all terminals automatically:
CDK_TEST_MINT_URL: CLN mint URLCDK_TEST_MINT_URL_2: LND mint URLCDK_ITESTS_DIR: Temporary directory with all dataAll commands work from any terminal - they automatically find the running environment.
# Get node information
just ln-cln1 getinfo
just ln-cln2 getinfo
just ln-lnd1 getinfo
just ln-lnd2 getinfo
# Create and pay invoices
just ln-cln1 invoice 1000 label "Test payment"
just ln-lnd1 payinvoice <bolt11>
# Check balances and channels
just ln-cln1 listfunds
just ln-lnd1 listchannels
just btc getblockchaininfo    # Blockchain status
just btc getbalance          # Wallet balance
just btc-mine 5              # Mine 5 blocks
just mint-info        # Show both mints' info
just mint-test        # Run integration tests
just restart-mints    # Recompile and restart mints
just regtest-status   # Check all components
just regtest-logs     # Show recent logs
The mprocs interface shows all component logs in real-time:
cln-mint: CDK mint connected to CLN (auto-started)lnd-mint: CDK mint connected to LND (auto-started)bitcoind: Bitcoin regtest node logscln-one: CLN node 1 logscln-two: CLN node 2 logslnd-one: LND node 1 logslnd-two: LND node 2 logs# Terminal 1: Start environment
just regtest
# Terminal 2: Create invoice and pay
just ln-cln1 invoice 1000 test "Test payment"
just ln-lnd1 payinvoice <bolt11_from_above>
just ln-cln1 listinvoices
just ln-lnd1 listpayments
# Terminal 1: Keep regtest running
just regtest
# Terminal 2: After making code changes
just restart-mints    # Recompiles and restarts both mints
just mint-info       # Test the changes
just mint-test       # Run integration tests
# Terminal 1: Start environment
just regtest
# Terminal 2: Use environment variables
cargo run --bin cdk-cli -- --mint-url $CDK_TEST_MINT_URL mint-info
cargo run --bin cdk-cli -- --mint-url $CDK_TEST_MINT_URL_2 mint-info
# Query mint info directly
curl $CDK_TEST_MINT_URL/v1/info | jq
curl $CDK_TEST_MINT_URL/v1/keysets | jq
# Test both mints
curl http://127.0.0.1:8085/v1/info | jq
curl http://127.0.0.1:8087/v1/info | jq
All components run in a temporary directory:
$CDK_ITESTS_DIR/
├── bitcoin/              # Bitcoin regtest data
├── cln/
│   ├── one/             # CLN node 1 data
│   └── two/             # CLN node 2 data
├── lnd/
│   ├── one/             # LND node 1 data
│   │   ├── tls.cert
│   │   └── data/chain/bitcoin/regtest/admin.macaroon
│   └── two/             # LND node 2 data
├── cln_mint/            # CLN mint working directory
├── lnd_mint/            # LND mint working directory
├── start_cln_mint.sh    # Mint startup scripts
├── start_lnd_mint.sh
└── mprocs.yaml         # mprocs configuration
If not installed, the script will offer to install it:
# Automatic installation during regtest setup
just regtest
# Manual installation
cargo install mprocs
# Or via package manager
# Ubuntu/Debian: apt install mprocs
# macOS: brew install mprocs
Managed automatically via Nix development shell:
# If you need to restart just the mprocs interface
source /tmp/cdk_regtest_env
just regtest-logs
The environment creates a state file at /tmp/cdk_regtest_env that:
just commands to work from anywhereFrom within mprocs:
nix develop/tmp/cdk_regtest_env file existsecho $CDK_TEST_MINT_URLjust regtest-status to check component healthjust regtest-logsjust ln-cln1 getinfoCtrl+C in the original terminal to clean upjust regtest-logs# Find and kill processes using ports
sudo lsof -ti:8085 | xargs kill -9
sudo lsof -ti:8087 | xargs kill -9
# Clean up and restart
rm -f /tmp/cdk_regtest_env
just regtest
# Rebuild binaries
just build
just regtest
This environment provides everything needed for CDK development and testing in a single, easy-to-use interface! 🎉