Trustless Atomic Swaps for Bitcoin Ordinals via Lightning Network
TL;DR: Pay Lightning, get Ordinal. Trustless. No custody risk.
Sparkle Protocol is a production-proven standard for trustless trading of Bitcoin Ordinals using Lightning Network payments.
The Problem:
The Solution - Sparkle Swap:
How It Works:
Sparkle Protocol provides a trustless mechanism for trading Bitcoin Ordinals with Lightning payments:
If you're building ordinal marketplace infrastructure and want Lightning payments without custody risk, Sparkle Swap provides the atomic swap mechanism.
The core SDK implements a frozen specification with safety-first design:
Seller provides Hold Invoice — the app never generates payment hashes. This eliminates custodial key management and ensures atomic settlement via Lightning infrastructure.
Every PSBT construction REFUSES unless ALL gates pass:
| Gate 1 | Funding UTXO exists | Fees from external funding, not Ordinal |
| Gate 2 | Output[0] = Input[0] | Ordinal value preserved exactly |
| Gate 3 | Affiliates ≤3, ≤5% each | Anti-griefing caps enforced |
| Gate 4 | Timelock + 12 blocks | Time-bandit protection |
| Gate 5 | Indexer verification | Ownership truth check |
Clean separation — plug your own backends:
NIP-17 Gift Wrap + NIP-44 XChaCha20-Poly1305 encryption for completely private trades. No public offers, no chain analysis.
For curious readers who want the big picture.
For protocol designers, security engineers, and researchers.
For developers considering a proof-of-concept.
Sparkle Protocol's security model is based on cryptographic guarantees, not trust:
Sparkle provides the first trustless atomic swap mechanism specifically designed for ordinal trading with Lightning settlement.
Sparkle Protocol provides working TypeScript implementations for building ordinal trading infrastructure:
{"p": "sparkle"} inscriptions and composes traits.Technical Stack: TypeScript, @scure/btc-signer, @noble/hashes, @noble/curves for Taproot/Schnorr.
Transaction Sizes: Claim TX: 142 vbytes (~$0.50 at 20 sat/vB) | Refund TX: 138 vbytes (~$0.48)
Sparkle Protocol is a production-proven standard for Lightning-aware Bitcoin Ordinals metadata and atomic trading flows.
The protocol defines metadata structures for Bitcoin Ordinals inscriptions that enable Lightning Network payment integration and recursive parent-child composition patterns.
Instead of inscribing redundant data N times for a collection of N Ordinals, Sparkle defines a pattern where:
All data remains on Bitcoin. No off-chain storage or centralized databases required.
Sparkle Protocol was created by David A. Michael as a production-proven standard for integrating Bitcoin Ordinals with Lightning Network atomic swaps.
Sparkle Protocol does NOT:
Sparkle Protocol is suitable for:
// Buyer Claim Path (hashlock)
OP_SHA256 <payment_hash> OP_EQUALVERIFY
<buyer_pubkey> OP_CHECKSIG
// Seller Refund Path (timelock)
<locktime> OP_CHECKLOCKTIMEVERIFY OP_DROP
<seller_pubkey> OP_CHECKSIG
| Approach | Trust Model | Payment Speed | Custody Risk | Lightning Support |
|---|---|---|---|---|
| Custodial Marketplace | Trust marketplace | Instant | High - they hold your assets | Varies |
| PSBT-based Trading | Trustless | ~10 min (on-chain) | None | No |
| Sparkle Swap | Trustless (atomic) | Instant (Lightning) | None | Native |
Note: Sparkle Swap combines the speed of custodial solutions with the trust model of PSBT trading.
Sparkle Protocol is designed for integration with existing NFT marketplaces through a standardized detection and trading mechanism. Marketplaces can identify Sparkle-enabled ordinals by parsing inscription metadata for protocol markers.
Ordinals inscribed with Sparkle Protocol metadata display a distinctive badge on
marketplace interfaces, signaling Lightning Network trading capability. This is achieved
through indexer modification to detect the protocol signature: {"p": "sparkle", "v": 1}
A critical innovation is the reinscription bridge mechanism, allowing existing ordinals to be upgraded with Lightning capability without modifying the original inscription:
{
"p": "sparkle",
"op": "upgrade",
"original": "existing_ordinal_inscription_id",
"lightning": {
"enabled": true,
"bridged_at": block_height
}
}
This preserves the provenance and authenticity of the original inscription while adding Lightning Network functionality. The reinscription creates a child inscription that references the parent, maintaining the chain of ownership.
| Component | Function | Integration Point |
|---|---|---|
| Marketplace UI | Display Sparkle badge | Frontend modification |
| Indexer | Detect protocol metadata | Parser enhancement |
| Lightning Backend | Handle Lightning payments via LND or Core Lightning | Backend integration |
| Trade Executor | Atomic swap coordination | Sparkle coordinator layer |
The integration requires minimal changes to existing marketplace infrastructure, primarily involving Lightning node integration (LND or Core Lightning) and UI modifications to display Lightning-enabled status. Sparkle Protocol provides the complete coordination layer.
| Layer | Components | Function |
|---|---|---|
| Layer 2: Lightning | Lightning Nodes, HTLC Channels, State Channels | Sub-second payment, ~10min ownership |
| Protocol Layer | Sparkle Coordinator, Trade Validators, Indexers | Non-custodial trade facilitation and state management |
| Layer 1: Bitcoin | Ordinal Inscriptions, Taproot Scripts, Bitcoin Blockchain | Base layer security and finality |
Schnorr signatures and Tapscript enable compact, private atomic swaps on Bitcoin.
BOLT-compatible payment hash links Lightning invoice to on-chain ordinal claim.
2x safety margin on refund timeout protects against race conditions and reorgs.
| Feature | Custodial Markets | PSBT Trading | Sparkle Swap |
|---|---|---|---|
| Trust Required | Full custody trust | None | None (atomic) |
| Payment Speed | Instant | ~10 min on-chain | Instant (Lightning) |
| Lightning Support | Some | No | Native |
| Can Steal Funds | Yes (they hold keys) | No | No |
A trustless atomic swap mechanism for trading Bitcoin Ordinals via Lightning payments. Uses established hashlock cryptography (HTLC pattern) applied specifically to ordinal trading.
If you want to trade ordinals with Lightning payments and zero custody risk, Sparkle Swap provides the atomic swap mechanism. Open source, MIT licensed.
import { createSparkleSwapAddress, generatePreimage } from 'sparkle-protocol';
// Generate cryptographic secret (shared with Lightning invoice)
const { preimage, paymentHash } = generatePreimage();
// Create Taproot swap address with two spending paths
const swap = createSparkleSwapAddress({
paymentHash, // SHA256(preimage) - same as Lightning payment_hash
buyerPubkey, // Buyer's compressed pubkey (33 bytes)
sellerPubkey, // Seller's compressed pubkey (33 bytes)
refundLocktime: currentBlock + 288, // 48 hours delta-safe
network: 'mainnet', // switch to 'testnet' only for sandbox dry-runs
});
console.log('Swap Address:', swap.address);
// tb1p9796mv7hs78lrw3t9xcspjkk558zwy940cdy8q277qfyn9k0x8xsl448v8
// Seller sends Ordinal to this address
// Buyer pays Lightning invoice with same payment_hash
// Payment reveals preimage - Buyer claims Ordinal on-chain
import { buildClaimTransaction } from 'sparkle-protocol';
// After paying Lightning invoice, buyer knows the preimage
const claimTx = buildClaimTransaction({
swapAddress: swap,
fundingTxid: 'abc123...', // TXID where Ordinal is locked
fundingVout: 0,
fundingAmount: 10000n, // sats
preimage, // Revealed by Lightning payment
buyerPrivkey,
destinationAddress: 'bc1p...',
feeRate: 2, // sat/vbyte
});
// Broadcast claimTx.txHex to claim the Ordinal
console.log('Claim TXID:', claimTx.txid); // 142 vbytes
Core Protocol - COMPLETE:
Mainnet Proven: