generated from vercel/ai-chatbot
-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Labels
Description
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
- 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)
- Background Service: Create service that checks for invoice statuses as soon as the user opens the wallet component.
- State Management: Track invoice checking state across app sessions, using local storage and nip-44.
- 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
Labels
Type
Projects
Status
Done