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 091aa4a644 fix: LNbits API version compatibility in get-lnbits-key.sh (#10)
Tracks Gitea issue token-gated-economy #19.

## Problem
LNbits 0.12 (released late 2024) removed the superuser wallet creation
API (POST /api/v1/wallet with X-Api-Key: <superuser-id>). The existing
script would silently fall through to generic manual instructions with
no explanation, leaving operators confused.

## Changes to scripts/bitcoin-ln-node/get-lnbits-key.sh
1. **Version detection** — calls GET /api/v1/health and parses
   `server_version` from the JSON response via python3. Version is
   printed at the start. If the endpoint is unreachable the script dies
   with a clear message. If the version field is absent (unexpected
   future change) it defaults to "0.12.0" (modern path) with a warning.

2. **Version-branched flow**
   - >= 0.12: skips superuser API entirely; prints a numbered 5-step
     walk-through to the Admin UI at /admin, then always prints the
     export template.
   - < 0.12: runs the existing superuser detection (env file → secrets
     file → lnbits.log grep) and wallet creation API. Falls back to
     manual instructions on failure, same as before.

3. **SQLite fallback removed** — the `sqlite3 "$DB_FILE" "SELECT id FROM
   accounts WHERE is_super_user=1"` block targeted the wrong schema on
   0.12+ and is redundant given the version branch. Deleted entirely.

4. **Export template always printed** — `print_export_template()` helper
   is called in every exit path (both version branches, all fallbacks).
   Template always shows:
     export LNBITS_URL="http://bore.pub:<PORT>"
     export LNBITS_API_KEY="..."

## Verified
- bash -n: syntax OK
- version_gte() passes all edge cases (0.12.0 == 0.12.0, 0.12.3 > 0.12.0,
  1.0.0 > 0.12.0, 0.11.9 < 0.12.0, 0.9.0 < 0.12.0)
- >= 0.12 output path confirmed via bash simulation
- sqlite3/SQLite strings absent from final file
- Script exits 0 in all manual-instruction paths (not an error)

## No changes to setup.sh (out of scope per task spec)
2026-03-18 23:23:17 +00:00
..