This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
token-gated-economy/scripts/bitcoin-ln-node
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
..