blitz_api/app/lightning
Justin Sharp 6b3acf0239 fix: handle missing fields in CLN invoice data gracefully
Fixes #129, #128, and addresses part of raspiblitz/raspiblitz#3182

BOLT12 offers, keysend payments, and certain CLN invoice types don't
always include all fields that the API expects, causing KeyError
exceptions that crash the web interface.

Changes:
- Modified Invoice.from_cln_json() to use .get() with safe defaults
  for all potentially missing fields (bolt11, amount_msat, payment_hash,
  description, label, status, etc.)
- Added fallback logic for amount_msat to use amount_received_msat
  when the primary field is missing
- Enhanced InvoiceState.from_cln_json() to handle unknown/missing
  statuses gracefully with logging instead of raising exceptions

This allows the web interface to display all CLN invoices including
BOLT12 payments from services like OCEAN mining pool, while preserving
all existing payment data for standard BOLT11 invoices.

Tested on RaspiBlitz v1.12.0 with Core Lightning and OCEAN mining
pool BOLT12 payouts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:00:05 +01:00
..
impl feat: replace call_script func with better func 2025-05-06 09:16:46 +02: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 fix: handle missing fields in CLN invoice data gracefully 2025-11-10 10:00:05 +01:00
router.py chore: run ruff format and isort 2025-05-06 09:16:46 +02:00
service.py feat: make config loading more flexible 2025-03-23 17:43:39 +01:00
utils.py feat: implement Ruff as a linter; fix given errors 2023-06-25 07:17:00 +02:00