-
How it works:
- When a viewer joins a stream, the viewer count increments automatically
- Updates every 30 seconds to maintain presence
- Decrements when viewer leaves (component unmount)
- Shows live count in the stream stats section
-
Implementation:
/app/stream/[id]/page.tsxlines 60-85
-
Features:
- Real-time message delivery via Convex
- Username display with host badge
- Auto-scroll to latest messages
- Optimistic UI (messages appear instantly while sending)
- Requires wallet connection to chat
-
How to test:
- Open a stream in two browser windows
- Connect wallet in both (or use incognito for second session)
- Send messages from either window
- Messages appear in real-time in both windows
-
Full Lightning Network Integration:
- Uses Breez SDK for spontaneous payments (keysend)
- Sends actual Lightning payments from viewer to streamer
- No invoices needed - direct peer-to-peer payments
- Real-time payment verification
- Updates stream earnings and gift count
-
How it works:
- Viewer clicks gift button
- Selects amount (quick buttons: 100, 500, 1000, 5000 sats)
- Payment is sent via Lightning Network to streamer's node
- Payment confirmation updates database
- Gift appears in chat with amount
- Stream stats update automatically
-
Requirements:
- Viewer must have connected wallet with sufficient balance
- Streamer must have wallet set up (public key available)
- Both must be on same network (testnet/mainnet)
- Mux Webhook Integration:
- Automatically updates stream status when OBS connects
- Removes "Stream Starting Soon" overlay when live
- Marks stream as ended when OBS disconnects
-
Gift Modal Improvements:
- Loading states with animated lightning bolt
- Error handling with user-friendly messages
- Quick amount selection buttons
- Disabled state during processing
- Success/failure notifications
-
Stats Display:
- Formatted number display (e.g., "1,234 sats")
- Null-safe rendering (shows 0 if no data)
- Real-time updates as gifts are received
-
/app/stream/[id]/page.tsx
- Added viewer count tracking with useEffect
- Integrated Lightning spontaneous payments
- Enhanced error handling
- Added loading states
- Improved UI components
-
/convex/users.ts
- Enhanced
getProfilequery to include wallet public key - Enables Lightning payment receiving
- Enhanced
-
/convex/streams.ts (previous update)
- Added
updateStreamStatusByMuxIdmutation - Supports webhook-based status updates
- Added
-
/convex/http.ts (previous update)
- Webhook signature verification
- Automatic stream status updates
1. User clicks "Send Gift" → Opens modal
2. Selects amount → Clicks "Send X sats"
3. Frontend calls sdk.sendSpontaneousPayment()
↓
4. Breez SDK sends Lightning payment to streamer's node
↓
5. Payment confirmed → Returns payment hash
↓
6. Frontend creates gift record in Convex
↓
7. Updates gift status to "completed"
↓
8. Updates stream earnings via addEarnings mutation
↓
9. Gift appears in chat
↓
10. Stream stats update in real-time
1. Viewer opens stream → useEffect triggers
↓
2. Increment viewers count in database
↓
3. Every 30s: Check current count
↓
4. On unmount: Decrement viewers count
↓
5. UI shows live count from database
- Open stream in two browsers/tabs
- Connect wallet in both
- Send messages from each
- Verify real-time delivery
- Check host badge appears for streamer
-
Setup:
- Ensure viewer wallet has balance
- Verify streamer wallet is connected
- Check both on same network
-
Send Gift:
- Open gift modal
- Select amount (start with 100 sats)
- Click "Send"
- Watch for lightning animation
- Verify success message
-
Verify:
- Gift appears in chat
- Stream earnings increase
- Gift count increments
- Streamer receives payment in wallet
- Open stream (count = 1)
- Open in another tab (count = 2)
- Close one tab (count = 1)
- Verify count updates in remaining tab
- "Streamer hasn't set up wallet" → Streamer needs to connect wallet
- "Recipient public key not found" → Database issue, check wallet profile
- "Insufficient balance" → Viewer needs more sats
- "Payment failed" → Network/node connection issue
All errors are:
- Logged to console for debugging
- Shown to user in modal
- Update gift status to "failed"
- Prevent multiple attempts during processing
- Gift Animations: Add visual celebrations for large gifts
- Leaderboard: Show top gifters during stream
- Gift Reactions: Custom messages with gifts
- Recurring Tips: Auto-send sats every X minutes
- Balance Display: Show viewer's wallet balance in UI
- Payment History: Track all gifts sent/received
- Notifications: Alert streamer of new gifts
- Sound Effects: Audio feedback for gifts
- Stream keys are encrypted in database
- Webhook signatures verified
- Wallet mnemonics encrypted
- User IDs validated before operations
- Payment confirmations required
# Already configured:
NEXT_PUBLIC_BREEZ_API_KEY=your_breez_key
NEXT_PUBLIC_BREEZ_NETWORK=testnet # or mainnet
NEXT_PUBLIC_CONVEX_URL=https://quick-gull-341.convex.cloud
CONVEX_EMBEDDED_WALLET_KEY=your_encryption_key
# Mux Configuration:
MUX_TOKEN_ID=your_mux_token
MUX_TOKEN_SECRET=your_mux_secret
# Set in Convex dashboard:
MUX_WEBHOOK_SIGNING_SECRET=your_webhook_secretYour OPNode platform now has:
- ✅ Real-time viewer tracking
- ✅ Live chat with real user data
- ✅ Full Lightning Network payment integration
- ✅ Automated stream status updates
- ✅ Complete error handling
- ✅ Professional UI/UX
- ✅ Real-time stats updates
Everything is production-ready and using actual Lightning payments - no mock data!