refactor(machine): wire LnbitsClient alongside LightningPubClient

3b.1 of the LP→LNbits migration: structurally introduce LnbitsClient
into services/lightning.ts without changing any runtime behavior.
All existing call sites still go through LightningPubClient.

  apps/machine/src/services/lightning.ts
    - import LnbitsClient from @bitSpire/lnbits
    - add `lnbitsServerPubkey` to LightningConfig
    - load it from runtime IPC config + VITE_LNBITS_SERVER_PUBKEY
      env var (env wiring proper happens in 3c)
    - module-level `_lnbitsRef: LnbitsClient | null`
    - in initializeLightningServices, instantiate LnbitsClient
      ONLY IF `CONFIG.lnbitsServerPubkey` is set (graceful no-op
      while the env hasn't been wired yet)
    - export `_getLnbitsClient()` for 3b.2+ call sites

  apps/machine/package.json
    - add `@bitSpire/lnbits: workspace:*` dependency

Verified: pnpm typecheck clean (14/14 turbo tasks, machine task
now executes since lnbits is a new dep).

Next: 3b.2 — drop the CLINK/ndebit cash-in flow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-05-13 12:56:01 +02:00
commit 7d0c19ed7f
3 changed files with 47 additions and 0 deletions

3
pnpm-lock.yaml generated
View file

@ -32,6 +32,9 @@ importers:
'@bitSpire/lightning':
specifier: workspace:*
version: link:../../packages/lightning
'@bitSpire/lnbits':
specifier: workspace:*
version: link:../../packages/lnbits
'@bitSpire/nostr-client':
specifier: workspace:*
version: link:../../packages/nostr-client