RTL/docker/cln/create-rune.sh
saubyk f518488ecb Clarify connected-mirror comment and pin the fixture rune path
Address review F7/F8 on #1625:

F7 (verification): the onchain.ts `connected === false` branch reads /v1/listfunds
(CLN's own connected field) and only buckets balance as inactive — it is not the
listPeerChannels mirror and does no close logic, so the coercion activates nothing
there. Reword the mirror comment, which inaccurately implied onchain.ts consumes it;
the mirror simply keeps the documented backward-compat `connected` field defined.

F8: hardcode the rune path in create-rune.sh to /root/.lightning/rtl.rune so it
matches the volume mount, healthcheck and RTL runePath instead of deriving it from
${LIGHTNINGD_DATA}, removing the silent-divergence risk.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 22:01:23 -07:00

31 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Ensure the RTL rune exists. One quick, idempotent attempt:
# - already have it -> succeed
# - RPC up, createrune works -> write it, succeed
# - RPC not ready / failure -> fail, so the caller retries
#
# This is invoked from the cln healthcheck (not a one-shot poststart hook) so a
# transient RPC-startup race self-heals on the next healthcheck tick instead of
# permanently wedging the stack. Stores the rune as LIGHTNING_RUNE="<rune>", the
# format RTL reads via its runePath. POSIX sh compatible.
set -u
# Hardcoded to match the single source of truth used everywhere else in the fixture:
# the cln volume mount (cln_data:/root/.lightning), the healthcheck's `test -f`, and
# RTL's runePath (/cln/rtl.rune, /cln being cln_data mounted read-only). Keep these in
# lockstep — do not switch to ${LIGHTNINGD_DATA}, which would silently diverge if the
# image's data dir ever changed while the mounts/healthcheck stayed on /root/.lightning.
RUNE_FILE="/root/.lightning/rtl.rune"
[ -f "${RUNE_FILE}" ] && exit 0
lightning-cli --network="${LIGHTNINGD_NETWORK}" getinfo >/dev/null 2>&1 || exit 1
rune=$(lightning-cli --network="${LIGHTNINGD_NETWORK}" createrune 2>/dev/null \
| grep -o '"rune"[[:space:]]*:[[:space:]]*"[^"]*"' \
| sed -e 's/.*"rune"[[:space:]]*:[[:space:]]*"//' -e 's/"$//')
[ -n "${rune}" ] || exit 1
printf 'LIGHTNING_RUNE="%s"\n' "${rune}" > "${RUNE_FILE}"