refactor: collapse fakewallet/regtest wrappers into single dev CLI
Replaces the two parallel scripts (fakewallet.sh, regtest.sh) with one
modules/dev-env/scripts/dev.sh — `dev up [--fakewallet|--regtest]`,
plus `down|logs|shell`. Default mode is fakewallet (no docker, no
chains, instant), matching what the prior scaffold did with two scripts
but giving consumers one command and one verb-set to learn.
Drops the now-redundant `lnbits.backend` enum and `features.fakewallet`
option from core.nix. Backend selection is the dev CLI's runtime
concern; a NixOS-level option would be a second knob that can disagree
with the CLI flag at runtime. `lnbits.{host,port}` stay (bind addr,
useful to docs and any later service path). `features.regtest` stays
(gates docker engine installation — consumers who'll never use the
regtest mode shouldn't pay for the container engine).
Strips modules/lnbits.nix entirely. The dev CLI runs lnbits ad-hoc; if
a NixOS-managed lnbits service becomes a real ask later, re-add a
focused module then.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bbaa80d8a3
commit
94a7c5f97c
7 changed files with 66 additions and 157 deletions
53
modules/dev-env/scripts/dev.sh
Executable file
53
modules/dev-env/scripts/dev.sh
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bash
|
||||
# dev — single entry point for spinning up an LNbits dev environment.
|
||||
#
|
||||
# dev up [--fakewallet|--regtest] start lnbits (default: --fakewallet)
|
||||
# dev down tear down whatever's running
|
||||
# dev logs follow lnbits (and docker, if regtest) logs
|
||||
# dev shell drop into the lnbits venv (or regtest container)
|
||||
#
|
||||
# Modes:
|
||||
# --fakewallet (default) LNBITS_BACKEND_WALLET_CLASS=FakeWallet — no docker,
|
||||
# no chains, instant. Good for extension / UI work.
|
||||
# --regtest docker-compose up the multi-node regtest stack
|
||||
# (LND + CLN + Eclair + bitcoind + electrs), then
|
||||
# start lnbits pointed at the LND-rest endpoint.
|
||||
# Wraps lnbits/legend-regtest-enviroment.
|
||||
#
|
||||
# Skeleton — no real wiring yet. The substantive pass will:
|
||||
# - locate the lnbits checkout via inputs.lnbits-src (or a configurable path)
|
||||
# - locate the regtest docker repo via config.lnbits-sensei.devEnv.regtest.repoUrl
|
||||
# - bring up containers, wait-for-it, populate LND credentials, exec lnbits
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cmd="${1:-up}"
|
||||
shift || true
|
||||
|
||||
mode="fakewallet"
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--fakewallet) mode="fakewallet"; shift ;;
|
||||
--regtest) mode="regtest"; shift ;;
|
||||
*) echo "dev: unknown flag: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$cmd" in
|
||||
up)
|
||||
echo "dev up --$mode: TODO — wire substantive startup in next pass."
|
||||
;;
|
||||
down)
|
||||
echo "dev down: TODO — wire teardown in next pass."
|
||||
;;
|
||||
logs)
|
||||
echo "dev logs: TODO — tail lnbits + (docker logs if regtest) here."
|
||||
;;
|
||||
shell)
|
||||
echo "dev shell: TODO — drop into venv / regtest container here."
|
||||
;;
|
||||
*)
|
||||
echo "Usage: dev {up|down|logs|shell} [--fakewallet|--regtest]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# fakewallet.sh — symmetric no-op for parity with regtest.sh.
|
||||
#
|
||||
# FakeWallet is the default LNbits backend. There is nothing to start,
|
||||
# nothing to stop, nothing to log: LNbits with `LNBITS_BACKEND_WALLET_CLASS=FakeWallet`
|
||||
# just runs.
|
||||
#
|
||||
# This wrapper exists purely so the dev experience is symmetric with
|
||||
# the regtest stack:
|
||||
#
|
||||
# fakewallet up # no-op, prints reassurance
|
||||
# fakewallet down # no-op, prints reassurance
|
||||
# fakewallet logs # tails lnbits' own logs (not a backend's)
|
||||
# fakewallet shell # no-op (no container to enter)
|
||||
#
|
||||
# Muscle memory wins. `regtest up` and `fakewallet up` mean the same
|
||||
# thing — "make the chosen backend ready" — even when one is a docker
|
||||
# stack and the other is a constant.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# TODO(skeleton): wire the substantive variants in a later pass.
|
||||
# `up` / `down` / `shell` stay no-ops by design; `logs` should
|
||||
# `journalctl --user -u lnbits` (or whatever unit the lnbits module
|
||||
# ends up declaring) so the dev still has a single place to look.
|
||||
|
||||
case "${1:-up}" in
|
||||
up | down | shell)
|
||||
echo "FakeWallet is the default — nothing to start."
|
||||
;;
|
||||
logs)
|
||||
echo "fakewallet logs: TODO — tail the lnbits service log here."
|
||||
;;
|
||||
*)
|
||||
echo "Usage: fakewallet {up|down|logs|shell}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# regtest.sh — wrapper around a Bitcoin/Lightning regtest docker stack.
|
||||
#
|
||||
# Mirrors the workflow of `lnbits/legend-regtest-enviroment` (LND + CLN
|
||||
# + Eclair + bitcoind + electrs). Cloned to
|
||||
# `${dev-env.root}/local/docker/regtest/` by the bootstrap script
|
||||
# (later pass); this wrapper just dispatches `up` / `down` / `logs` /
|
||||
# `shell` to the underlying docker-compose stack.
|
||||
#
|
||||
# Symmetric with fakewallet.sh so the dev experience reads the same
|
||||
# whether you're on the default FakeWallet path or the regtest stack:
|
||||
#
|
||||
# regtest up # boot the regtest stack
|
||||
# regtest down # tear it down
|
||||
# regtest logs # tail compose logs
|
||||
# regtest shell # drop into a node container
|
||||
#
|
||||
# Once `regtest up` is healthy, point LNbits at the appropriate
|
||||
# backend (LndRestWallet / CoreLightningWallet) by flipping
|
||||
# `lnbits-sensei.lnbits.backend` and rebuilding.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# TODO(skeleton): replace with real dispatcher in the substantive pass.
|
||||
# Intended shape:
|
||||
# case "${1:-}" in
|
||||
# up) docker compose -f "${REGTEST_DIR}/docker-compose.yml" up -d ;;
|
||||
# down) docker compose -f "${REGTEST_DIR}/docker-compose.yml" down ;;
|
||||
# logs) docker compose -f "${REGTEST_DIR}/docker-compose.yml" logs -f ;;
|
||||
# shell) docker compose -f "${REGTEST_DIR}/docker-compose.yml" exec "${2}" sh ;;
|
||||
# *) usage ;;
|
||||
# esac
|
||||
|
||||
echo "regtest: TODO — substantive implementation lands in a later pass."
|
||||
echo "See modules/dev-env/scripts/regtest.sh for the intended dispatcher shape."
|
||||
exit 0
|
||||
Reference in a new issue