Atomic Swaps and HTLCs

13 min readarticleIncludes quiz · 1 questions

Imagine swapping a $20 bill for euros with a stranger, but with a guarantee that either both of you get what you want or neither of you loses anything. That is an atomic swap — trustless exchange enforced by cryptography.

Understand the cryptographic magic that makes Lightning payments atomic and trustless.

Hash Time-Locked Contracts (HTLCs):

  • Hash Lock: Payment requires a secret preimage
  • Time Lock: Refund after timeout
  • Atomic: All-or-nothing execution
  • Trustless: No intermediary can steal funds

HTLCs enable multi-hop payments where either everyone gets paid or no one does.

HTLC Mechanics
HTLC Mechanics
Key Takeaway

Atomic swaps use the same hash time-locked contracts (HTLCs) that power Lightning routing. They enable cross-chain trading without trusting an exchange or a counterparty.

Test Your Knowledge

1 questions · Passing score: 80%

Enjoying these lessons?

Get a free Bitcoin lesson in your inbox every week. Join thousands of learners.

Free forever. No spam. Unsubscribe anytime.