Commit Graph

2 Commits

Author SHA1 Message Date
alexpaynex
2896d5bbd6 fix: LNbits API version compatibility in get-lnbits-key.sh (#10)
Tracks Gitea issue token-gated-economy #19.

## Problem
LNbits 0.12 removed the superuser wallet creation API. The old script
silently fell through to generic manual instructions with no explanation.
version_gte() using `sort -V` was also not supported on macOS (BSD sort).

## Changes to scripts/bitcoin-ln-node/get-lnbits-key.sh

1. **Unreachable health check — warning + exit 0** (was hard die)
   curl uses `|| true` — if response is empty, warns the operator to
   start LNbits, prints the export template, and exits 0.

2. **macOS-safe version_gte()** — replaced `sort -V -C` (GNU-only) with:
   - Primary: python3 inline script (parses major.minor.patch as int lists)
   - Fallback: pure-bash numeric comparison (no external tools required)
   All 6 test cases pass: 0.12.0==, 0.12.3>, 1.0.0>, 0.11.9<, 0.9.0<,
   0.12.0>0.11.9.

3. **Version detection** — calls GET /api/v1/health, parses server_version
   via python3, prints it. Falls back to "0.12.0" (safe modern default)
   with a warning if unparseable.

4. **Version-branched flow**
   - >= 0.12: skips superuser API; prints 5-step Admin UI walk-through
     (/admin → Users → Create User → wallet → API Info → Admin key).
   - < 0.12: existing superuser detection (env file → secrets file →
     lnbits.log grep) + wallet creation API, unchanged.

5. **SQLite fallback removed** — the sqlite3 "SELECT id FROM accounts
   WHERE is_super_user=1" block targeted wrong schema on 0.12+. Deleted.

6. **Export template always printed** via print_export_template() helper
   called in every exit path: unreachable, >=0.12, <0.12 success, fallbacks.

## Changes to scripts/bitcoin-ln-node/setup.sh
Added LNbits version compatibility note to the "Done" summary so operators
know upfront that >=0.12 requires the Admin UI path.

## Verified
- bash -n syntax OK on both files
- version_gte(): 6/6 test cases correct with python3 comparator
- Unreachable-LNbits path: warns, prints template, exits 0 (simulated)
- No sqlite3/sort -V references remain in get-lnbits-key.sh
2026-03-18 23:27:04 +00:00
alexpaynex
ca94c0a9e5 Add Bitcoin/LND/LNbits local node setup scripts and node diagnostics endpoint
- scripts/bitcoin-ln-node/setup.sh: one-shot installer for Bitcoin Core (pruned mainnet), LND, and LNbits on Apple Silicon Mac. Generates secrets, writes configs, installs launchd plists for auto-start.
- scripts/bitcoin-ln-node/start.sh: start all services via launchctl; waits for RPC readiness and auto-unlocks LND wallet.
- scripts/bitcoin-ln-node/stop.sh: graceful shutdown (lncli stop → bitcoin-cli stop).
- scripts/bitcoin-ln-node/status.sh: full health check (Bitcoin sync %, LND channels/balance, LNbits HTTP, bore tunnel). Supports --json mode for machine consumption.
- scripts/bitcoin-ln-node/expose.sh: opens bore tunnel from LNbits port 5000 to bore.pub for Replit access.
- scripts/bitcoin-ln-node/get-lnbits-key.sh: fetches LNbits admin API key and prints Replit secret values.
- artifacts/api-server/src/routes/node-diagnostics.ts: GET /api/admin/node-status (JSON) and /api/admin/node-status/html — Timmy self-diagnoses its LNbits/LND connectivity and reports issues.
2026-03-18 21:58:41 +00:00