← Back to Home

SIP-3: Lightning-Atomic NFT Trades

STATUS: DRAFT - NOT IMPLEMENTED
Type: Standard
Created: 2025-10-02
Author: David Michael

REQUIRES: Coordinator service (not built), Spark SDK integration, wallet support

Abstract

This specification defines the protocol for atomic NFT trades where Lightning payment settlement is cryptographically bound to PSBT finalization. It establishes the handshake flow, timeout rules, and failure handling to ensure buyer and seller atomicity.

Motivation

Standard Bitcoin transactions take ~10 minutes to confirm. Lightning enables sub-second payment, but linking it atomically to NFT ownership transfer requires careful protocol design to prevent:

Specification

Trade Flow

1. Seller → Coordinator: List NFT
   - Provide inscription ID, price (sats), PSBT transferring NFT

2. Buyer → Coordinator: Accept offer
   - Request Lightning invoice

3. Coordinator → Buyer: HTLC invoice
   - Payment hash H = hash(preimage)
   - Timeout: 60 blocks (~10 hours)

4. Buyer → Lightning: Pay invoice
   - Payment routed via Lightning Network

5. Seller receives preimage P
   - Seller verifies hash(P) = H
   - Seller broadcasts signed PSBT

6. Coordinator monitors blockchain
   - After 1 confirmation: Release preimage to buyer
   - Trade complete

HTLC Timeout Rules

Timeout Value Rationale
Lightning invoice 60 blocks Enough time for PSBT broadcast + confirmations
PSBT broadcast Within 30 blocks After buyer pays, seller must broadcast quickly
Confirmation wait 6 blocks Standard finality threshold

Atomicity Guarantee

The protocol ensures atomicity through HTLC construction:

IF buyer pays Lightning invoice
    Seller learns preimage P
    Seller must broadcast PSBT to claim payment
    Coordinator cannot steal (doesn't know seller's keys)
ELSE
    Invoice expires, no payment captured
    Both parties refunded automatically

Failure Modes

1. Buyer Pays But PSBT Fails

Scenario: Buyer pays Lightning invoice, but seller's PSBT is invalid or double-spent.

Resolution:

2. Seller Broadcasts PSBT But Mempool Pinning

Scenario: Attacker broadcasts low-fee conflicting tx to block PSBT.

Mitigation:

3. Blockchain Reorg After Payment

Scenario: PSBT confirmed, then chain reorgs and tx disappears.

Resolution:

Coordinator API (Proposed)

POST /v1/trade/create
{
  "inscription_id": "abc123...i0",
  "price_sats": 100000,
  "seller_address": "bc1p...",
  "psbt": "cHNidP8BAH..."
}

Response:
{
  "trade_id": "uuid",
  "status": "pending"
}

---

GET /v1/trade/{trade_id}/invoice

Response:
{
  "payment_request": "lnbc1...",
  "payment_hash": "abc123...",
  "expires_at": 1234567890
}

---

POST /v1/trade/{trade_id}/finalize
{
  "payment_preimage": "def456..."
}

Response:
{
  "txid": "xyz789...",
  "confirmations": 0
}

Implementation Requirements

Coordinator Service Must:

  1. Validate PSBT transfers correct inscription to buyer
  2. Generate HTLC invoices via Spark SDK or LND
  3. Monitor Lightning payments and blockchain confirmations
  4. Enforce timeout rules and trigger refunds
  5. Provide WebSocket updates for trade status

Wallet Support Requires:

  1. PSBT creation for inscription transfers
  2. Lightning invoice payment via Spark SDK
  3. API integration with coordinator
  4. User confirmation flow (payment + PSBT signing)

Security Considerations

Coordinator Trust Assumptions

The coordinator can:

Mitigations

Current Status

NOT IMPLEMENTED. This specification describes the intended design. To use this protocol, someone must build:

  1. Coordinator service (~200 hours development)
  2. Wallet integration (Sparrow plugin, UniSat PR, etc.)
  3. Spark SDK integration for HTLC generation
  4. Testnet deployment and testing