Files
routstrd/tests
Paperclip Deployment Engineer 4f59168b5f feat: harden fallback chain — routstr-core Lightning invoice + NWC auto-pay
When the local wallet runs out of proofs, the fallback chain now:

1. Retries across ALL configured mints (createProviderToken patched —
   previously only topUp retried on 'Not enough proofs')
2. Creates a routstr-core Lightning invoice (POST /lightning/invoice)
   → uses 'topup' purpose when an existing API key is available
   → pays via NWC (payBolt11) if connected, then retries
   → otherwise surfaces invoice for manual payment + polls until paid/expired
3. Falls back to local wallet Lightning invoice + NWC funding

Hardening (15 new tests):
- SSRF protection: rejects non-HTTPS provider URLs (except localhost)
- Amount validation: clamps to [1, 1_000_000] sats
- bolt11 validation: must start with 'lnbc'
- invoice_id validation: must be non-empty string
- Fetch timeout: AbortController (10s) on invoice creation
- NWC exception handling: caught, not propagated
- Double-install idempotency: patch markers prevent re-patching
- Concurrent calls: no shared state corruption
- API key safety: never logged in error messages
- Poller lifecycle: stops after 84 attempts (~7min) or on expired status

New wallet adapter method:
- payBolt11(bolt11): pays externally-created invoices via NWC

Verified end-to-end:
- 50-request stress test: 44/50 success, 6 fallback triggers (fugu-ultra)
- Routstr-core topup: 64,781 → 114,340 msats (balance increased)
- Daemon stable post-stress (142MB RSS, immediate recovery)
- 48/48 tests pass (33 existing + 15 hardening)
2026-07-19 15:47:27 +00:00
..
2026-07-11 16:33:28 +02:00
2026-07-15 15:56:33 +00:00