Skip to main content

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

The useProcessPaymentString hook (hooks/coco/useProcessPaymentString.ts) handles all Lightning payment formats:

Supported Formats

  1. Lightning invoices (BOLT11)
  2. Lightning addresses (user@domain.com)
  3. LNURL-pay URLs (lnurlp://…)
  4. Ecash tokens (cashuA…)
  5. NUT-18 payment requests (creqA…)
  6. HTTP/HTTPS mint URLs
  7. Nostr pubkeys (npub…)

Invoice Detection

From hooks/coco/useProcessPaymentString.ts:333-367.

Lightning Utilities

Invoice Parsing

The helper/coco/utils.ts module provides Lightning invoice utilities:

Extract Amount

Extract Timestamp

Validate Invoice

URI Trimming

Normalizes Lightning URIs by removing common prefixes:
From helper/coco/utils.ts:162-185.

LNURL Support

Lightning Address Validation

LNURL-Pay URL Validation

Request Invoice from LNURL

From helper/coco/utils.ts:284-309.

Melt Operations

The useMeltWithHistory hook manages Lightning payment execution:

Melt Flow

  1. Prepare melt quote - Get quote from mint for invoice amount + fees
  2. Execute melt - Burn ecash tokens and pay Lightning invoice
  3. Track history - Record melt operation in transaction history
  4. Handle errors - Rollback on failure, preserve tokens
From 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

The useLightningOperations hook provides high-level Lightning operations:
From hooks/coco/useLightningOperations.ts:3.

Scan History Integration

All Lightning scans are tracked:
Scan sources include:
  • qr - QR code scanner
  • paste - Clipboard paste
  • deeplink - App deep link
  • nfc - 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