Enhance documentation for Lightning Wallet integration and real-time features
- Expanded CLAUDE.md to include detailed information about the new Wallet Module, emphasizing its functionality for Lightning wallet management and real-time balance updates. - Updated README.md to reflect the modular architecture, key features, and real-time wallet capabilities, including WebSocket configuration and connection management. - Added sections on WebSocket real-time features, including automatic balance updates, live notifications, and battery optimization strategies. These enhancements improve the clarity and accessibility of the wallet integration documentation, aiding developers in implementation and usage.
This commit is contained in:
parent
71cec00bfc
commit
23726f09ec
2 changed files with 116 additions and 3 deletions
37
CLAUDE.md
37
CLAUDE.md
|
|
@ -27,6 +27,7 @@ The application uses a plugin-based modular architecture with dependency injecti
|
|||
|
||||
**Core Modules:**
|
||||
- **Base Module** (`src/modules/base/`) - Core infrastructure (Nostr, Auth, PWA)
|
||||
- **Wallet Module** (`src/modules/wallet/`) - Lightning wallet management with real-time balance updates
|
||||
- **Nostr Feed Module** (`src/modules/nostr-feed/`) - Social feed functionality
|
||||
- **Chat Module** (`src/modules/chat/`) - Encrypted Nostr chat
|
||||
- **Events Module** (`src/modules/events/`) - Event ticketing with Lightning payments
|
||||
|
|
@ -79,7 +80,10 @@ const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB)
|
|||
**Available Services:**
|
||||
- `SERVICE_TOKENS.RELAY_HUB` - Centralized Nostr relay management
|
||||
- `SERVICE_TOKENS.AUTH_SERVICE` - Authentication services
|
||||
- `SERVICE_TOKENS.PAYMENT_SERVICE` - Lightning payment and wallet management
|
||||
- `SERVICE_TOKENS.VISIBILITY_SERVICE` - App visibility and connection management
|
||||
- `SERVICE_TOKENS.WALLET_SERVICE` - Wallet operations (send, receive, transactions)
|
||||
- `SERVICE_TOKENS.WALLET_WEBSOCKET_SERVICE` - Real-time wallet balance updates via WebSocket
|
||||
|
||||
**Core Stack:**
|
||||
- Vue 3 with Composition API (`<script setup>` style)
|
||||
|
|
@ -94,6 +98,7 @@ const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB)
|
|||
**Key Features:**
|
||||
- Nostr protocol client for decentralized social networking
|
||||
- Lightning Network integration for event ticketing
|
||||
- **Real-time wallet balance updates via WebSocket** - Automatic UI updates when payments are sent/received
|
||||
- PWA capabilities with service worker
|
||||
- Theme switching and language switching
|
||||
- Real-time connection status monitoring
|
||||
|
|
@ -113,6 +118,38 @@ const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB)
|
|||
- `src/pages/` - Route pages
|
||||
- `electron/` - Electron main process code
|
||||
|
||||
**Lightning Wallet Integration:**
|
||||
The app integrates with LNbits for Lightning Network wallet functionality with real-time balance updates:
|
||||
|
||||
**Core Wallet Services:**
|
||||
- `src/core/services/PaymentService.ts` - Centralized payment processing and wallet balance management
|
||||
- `src/modules/wallet/services/WalletService.ts` - Wallet operations (send, receive, transactions, pay links)
|
||||
- `src/modules/wallet/services/WalletWebSocketService.ts` - **Real-time balance updates via WebSocket**
|
||||
|
||||
**WebSocket Real-Time Features:**
|
||||
- **Automatic balance updates** when payments are sent or received
|
||||
- **Live transaction notifications** with toast messages
|
||||
- **Connection management** with automatic reconnection and exponential backoff
|
||||
- **Battery optimization** via VisibilityService integration (pauses when app not visible)
|
||||
- **Unit conversion handling** between sats and millisats for different LNbits WebSocket behaviors
|
||||
|
||||
**WebSocket Configuration** (in `app.config.ts`):
|
||||
```typescript
|
||||
websocket: {
|
||||
enabled: true, // Enable/disable WebSocket functionality
|
||||
reconnectDelay: 1000, // Initial reconnection delay
|
||||
maxReconnectAttempts: 5 // Maximum reconnection attempts
|
||||
}
|
||||
```
|
||||
|
||||
**How WebSocket Balance Updates Work:**
|
||||
- Connects to LNbits WebSocket: `wss://your-lnbits/api/v1/ws/{walletInkey}`
|
||||
- Handles both incoming and outgoing payment notifications
|
||||
- **Incoming payments**: Uses balance as-is (post-payment balance from LNbits)
|
||||
- **Outgoing payments**: Adjusts balance by subtracting payment amount (pre-payment balance from LNbits)
|
||||
- Updates stored in `PaymentService.updateWalletBalance()` for consistency
|
||||
- Triggers Vue reactivity to update UI components immediately
|
||||
|
||||
**Nostr Integration:**
|
||||
The app connects to Nostr relays using a custom NostrClient class built on nostr-tools. Key files:
|
||||
- `src/lib/nostr/client.ts` - Core Nostr client implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue