blitz_api/app/lightning
fusion44 1081b7161a
fix(lightning): get_ln_info returns stub in bitcoin-only mode
`ln` is only bound to LnNode() when `BAPI_LN_NODE != "none"`. Every
`await ln.X()` call in this file therefore NameErrors when the
operator runs in bitcoin-only mode.

The most-hit caller is NativePythonSystem.get_system_info() at
app/system/impl/native_python.py:32, which always reads
`lninfo.alias` and `lninfo.color` to populate SystemInfo. The
NameError there breaks the SSE warmup pipeline
(get_full_client_warmup_data_bitcoinonly in app/api/warmup.py:116):

  warmup_new_connections() — calls get_full_client_warmup_data_bitcoinonly()
  → get_system_info() (via NativePythonSystem)
  → get_ln_info()
  → NameError: name 'ln' is not defined

The exception bubbles into the asyncio.gather(), which means new
SSE subscribers in bitcoin-only mode never receive `btc_info` /
`system_info` / `installed_app_status`. Their dashboards stay empty
forever (only periodic `hardware_info` and `ping` events flow,
because those run on separate gather loops).

Two fixes in this commit:

1. Return a stub LnInfo from get_ln_info() when ln_node == "none".
   All required fields filled with empty strings / zeros; the stub
   round-trips through any caller that reads alias/color/num_*
   without error. Other ln-method callers (get_wallet_balance,
   list_invoices, ...) keep their original behavior — they'll only
   ever fire from LN-aware code paths anyway.

2. Drop the duplicate `if ln_node != "none": ln = LnNode()` block
   at lines 69-70 (clearly a merge artifact).

Operator workaround used until this lands: enable lnd. After this
fix, bitcoin-only mode works end-to-end against the nixblitz
plugin streamer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 19:18:39 +02:00
..
impl chore: clean up imports; add better LND error logging 2026-02-03 11:05:19 +01:00
docs.py feat: implement Ruff as a linter; fix given errors 2023-06-25 07:17:00 +02:00
exceptions.py feat: proper error handling resolving peer aliases 2023-05-01 20:48:10 +02:00
models.py chore: clean up imports; add better LND error logging 2026-02-03 11:05:19 +01:00
router.py chore: run ruff format and isort 2025-05-06 09:16:46 +02:00
service.py fix(lightning): get_ln_info returns stub in bitcoin-only mode 2026-05-07 19:18:39 +02:00
utils.py feat: implement Ruff as a linter; fix given errors 2023-06-25 07:17:00 +02:00