Skip to content

Store and check lightning invoices even if user closes app during checking #48

@sh1ftred

Description

@sh1ftred

Problem

Currently, if a user closes the chat app while lightning invoices are being checked, the checking process is interrupted and invoice status may be lost. This can lead to:

  • Missed payments
  • Incorrect balance tracking
  • User confusion about payment status
  • Potential loss of funds if invoices expire without proper handling

Expected Behavior

  • Lightning invoice checking should be persistent across app sessions
  • Invoice status should be stored and retrievable even if app is closed
  • System should resume checking from where it left off when app reopens
  • Users should see accurate invoice status regardless of app lifecycle

Technical Details

  • Implement persistent storage for lightning invoice data
  • Create background process for invoice checking that survives app closure
  • Add mechanism to resume interrupted invoice checks
  • Store invoice metadata (amount, status, expiration, etc.)
  • Implement retry logic for failed checks

Implementation Approach

  1. Persistent Storage: Store invoice data using nip-44 similar to how API keys are being stored right now. It should also be stored locally and synced when needed (like when invoices are successfully paid or created)
  2. Background Service: Create service that checks for invoice statuses as soon as the user opens the wallet component.
  3. State Management: Track invoice checking state across app sessions, using local storage and nip-44.
  4. Recovery Mechanism: Detect and handle interrupted checks on app restart. Just once after a restart. And show a toast if successfully paid.

Acceptance Criteria

  • Lightning invoices are stored persistently when created - nip44 + local storage, similar to API keys
  • Invoice checking happens every minute or when user opens the wallet.
  • App can resume checking from correct state on reopen by
  • Invoices are stored and invoices history is displayed to users inside the wallet. Users see accurate invoice status regardless of app lifecycle.
  • Edge cases handled (expired invoices, failed checks, network issues)
  • No data loss occurs during app closure/reopen cycles

Priority

High - critical for financial reliability and user trust

Comment any suggestions and improvements.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions