🤔 The Problem

Say Alice wants to send 100,000 sats to Bob.

But:

  • Alice only has on-chain Bitcoin.
  • Bob only uses the Lightning Network.

They want to swap — but without using a centralized exchange or trusted custodian.

Can they do it trustlessly?

Yes — with:

  • DIDs (Decentralized Identifiers)
  • Nostr (a decentralized messaging protocol)
  • Bitcoin + Lightning
  • HTLCs (Hashed Time-Locked Contracts)

🔗 A Simple Use Case

Let’s walk through a real-world example that almost anyone can understand:


💡 Scenario: On-chain to Lightning Swap

  1. Alice wants to pay 100k sats on-chain.
  2. Bob wants to receive 100k sats on Lightning.
  3. They don’t trust each other and want to swap trustlessly.

🧩 Enter DID + Nostr + HTLCs

✅ 1. Identity via DIDs on Nostr

  • Both Alice and Bob have DIDs tied to their Nostr pubkeys.
  • DIDs make it possible to verify identities and sign messages.
  • Alice posts a signed message to Nostr offering the swap.
{
  "type": "swap-offer",
  "from": "did:nostr:pubkeyalice",
  "to": "any",
  "amount": 100000,
  "direction": "onchain-to-lightning",
  "hashlock": "abcdef123456...",
  "expires_in": 3600
}

Bob sees it and replies with a signed acceptance.


📡 2. Coordinating via Nostr

  • The offer and acceptance are broadcast as ephemeral Nostr events.
  • Both parties agree on:
    • The amount
    • The hashlock
    • Timeouts
    • Where to send funds

No servers, no intermediaries — just pubkey-signed messages over a decentralized relay network.


🔐 3. The HTLC Swap

They now execute the swap using the same secret hash:

Alice (on-chain):

  • Sends 100k sats to a Bitcoin HTLC (can only be claimed with the secret before timeout).

Bob (Lightning):

  • Sends 100k sats to a Lightning HTLC (also locked with the same hash).

As soon as one party claims the funds, the preimage is revealed, and the other can claim theirs too.


✅ 4. Atomic Swap Complete

  • Bob claims the on-chain BTC → reveals the secret.
  • Alice uses the same secret to claim her Lightning BTC.
  • No one can cheat — it’s enforced by the HTLCs and timeouts.

✨ Why This Matters

This setup gives us:

Trustless swaps

No custodians or centralized services

Cross-layer interoperability

Identity-based coordination via Nostr DIDs

And it all works with:

  • Bitcoin
  • Lightning
  • DID documents
  • Open message relays

🔮 What’s Next?

  • Add wallet support for DID-authenticated swap offers over Nostr.
  • Explore multi-party or ring swaps.

🔗 TL;DR

DID + Nostr + HTLCs = trustless swaps across Bitcoin and Lightning, with identity and coordination baked in.

No middleman. Just keys, hashes, and the open web.