Overview
Sovran integrates Lightning Network payments through the Cashu protocol’s melt/mint operations. Users can pay Lightning invoices, send to Lightning addresses, and handle LNURL-pay requests.Payment String Processing
TheuseProcessPaymentString hook (hooks/coco/useProcessPaymentString.ts) handles all Lightning payment formats:
Supported Formats
- Lightning invoices (BOLT11)
- Lightning addresses (user@domain.com)
- LNURL-pay URLs (lnurlp://…)
- Ecash tokens (cashuA…)
- NUT-18 payment requests (creqA…)
- HTTP/HTTPS mint URLs
- Nostr pubkeys (npub…)
Invoice Detection
hooks/coco/useProcessPaymentString.ts:333-367.
Lightning Utilities
Invoice Parsing
Thehelper/coco/utils.ts module provides Lightning invoice utilities:
Extract Amount
Extract Timestamp
Validate Invoice
URI Trimming
Normalizes Lightning URIs by removing common prefixes:helper/coco/utils.ts:162-185.
LNURL Support
Lightning Address Validation
LNURL-Pay URL Validation
Request Invoice from LNURL
helper/coco/utils.ts:284-309.
Melt Operations
TheuseMeltWithHistory hook manages Lightning payment execution:
Melt Flow
- Prepare melt quote - Get quote from mint for invoice amount + fees
- Execute melt - Burn ecash tokens and pay Lightning invoice
- Track history - Record melt operation in transaction history
- Handle errors - Rollback on failure, preserve tokens
hooks/coco/useMeltWithHistory.ts:1-12.
Payment Flows
Direct Invoice Payment
When scanning an invoice with an amount:Lightning Address Payment
When sending to a Lightning address:NFC Lightning Detection
NFC payments can detect Lightning invoices and redirect to the appropriate flow:Lightning Operations Hook
TheuseLightningOperations hook provides high-level Lightning operations:
hooks/coco/useLightningOperations.ts:3.
Scan History Integration
All Lightning scans are tracked:qr- QR code scannerpaste- Clipboard pastedeeplink- App deep linknfc- NFC tap payment
Key Features
BOLT11 Support
Full support for Lightning invoices with amount extraction and validation
LNURL Integration
Native LNURL-pay and Lightning address support without external libraries
Automatic Routing
Smart routing based on invoice amount and mint availability
NFC Detection
Automatic detection and handling of Lightning invoices via NFC
Related Documentation
- Ecash Tokens - Cashu token handling
- NFC Payments - NFC payment flows
- QR Scanner - QR code scanning