One Secret, Two Clocks, No Middleman: How Atomic Swaps Work

In 2017, Litecoin and Decred traded across two chains with no exchange and no trust. The exact path an atomic swap takes through HTLCs — why the two timelocks must not match, and why bridges won anyway.
One Secret, Two Clocks, No Middleman: How Atomic Swaps Work
PinchyCC, CC BY 4.0, via Wikimedia Commons

—

September 20, 2017. Charlie Lee, creator of Litecoin, posts a transaction hash on Twitter: he has just swapped LTC for DCR — Decred — with one of Decred’s developers. On-chain. Both chains. No exchange in the middle, no escrow agent, no “please wait 3–5 business days.” Neither party could have cheated the other even if they’d wanted to.

Review that case honestly and it gets stranger, not less strange, the longer you look. Cross-chain trading is supposed to be the hard problem — the thing bridges raise hundreds of millions to solve, the thing exchanges exist for. And here’s a 2017 trade doing it peer-to-peer with a protocol sketch posted on a forum in 2013 (Tier Nolan’s BitcoinTalk proposal, building on Sergio Demian Lerner’s 2012 P2PTradeX ideas).

This article walks the exact path that trade took. Not the whitepaper version — the version where you can see every lock click shut. And at the end I’ll say the uncomfortable part: why the industry, nine years later, mostly routes billions through bridges and exchanges instead.

The Shopping List

You need exactly four things. Two of them are objects, two of them are clocks.

Secret SA random number Alice picks — shown to nobody
Hash H(S)SHA-256 of the secret — shown to everybody
Timelock THow long Alice’s side stays locked (say 48h)
Timelock T/2How long Bob’s side stays locked (24h — half)

That fourth item is the one everybody skims past, and it’s the load-bearing wall of the whole house. Hold that thought. First, the path.

One Secret, Two Clocks, No Middleman: How Atomic Swaps Work
Alexdarek, CC BY 4.0, via Wikimedia Commons

The Path, Step by Step

Step 1 — Alice locks the first side. Alice wants to trade 1 BTC for Bob’s 100 LTC. She generates a secret S, computes its hash, and broadcasts a special transaction on Bitcoin called a hash time-locked contract, or HTLC. The contract says: Bob may claim this 1 BTC if he presents the preimage of H(S) within 48 hours. Otherwise, everything refunds to Alice.

AliceI’ve locked 1 BTC on Bitcoin. Here’s the hash — not the secret, just its fingerprint. The contract is on-chain; verify it yourself.
BobChecking… Hash matches, amount matches, timelock is 48 hours. My side will use the same hash. Locking 100 LTC now.

Step 2 — Bob mirrors on the other chain. Bob broadcasts his own HTLC on Litecoin with the same hash but a shorter clock: Alice may claim these 100 LTC if she presents the preimage within 24 hours. Otherwise, refund to Bob.

Notice the asymmetry: Alice’s clock is 48h, Bob’s is 24h. This is not sloppiness. It is the protocol.

Step 3 — Alice claims, and the secret escapes. Alice wants the LTC, so she claims it by presenting S on Litecoin. The claim is a public transaction. The moment it confirms, the secret is published to the entire world — including to Bob, who is watching the Litecoin chain.

Step 4 — Bob sweeps the first side. Bob now has everything he needs: the preimage, freshly revealed on-chain. He presents S on Bitcoin within his remaining 24 hours and claims the 1 BTC. Both sides settled. Nobody trusted anybody.

Why the Clocks Must Not Match

Here’s the part worth burning into memory. What stops Alice from grabbing the LTC and walking away without ever revealing the secret? Nothing stops her from trying — and the asymmetric timelock is what makes the attempt pointless.

Run the failure cases:

  • Alice never claims the LTC. 24 hours pass, Bob’s contract refunds his 100 LTC. Alice’s BTC contract also expires at 48h and refunds her. Both sides unwound. No harm.
  • Alice claims at hour 23.9. The reveal hits Litecoin. Bob has — at minimum — the 24 hours remaining on Alice’s 48-hour Bitcoin contract to watch the LTC chain, extract S, and sweep the BTC. The reveal happened inside Bob’s safety margin.
  • Alice waits until her own refund is about to open, then claims. She can’t. If she claims before hour 48, the secret is public while Bob still has time. If she waits past hour 48, her own BTC refunds to her and the trade is simply off. There is no clock position where Alice gets both sides.

That’s the entire genius of the design, and it’s not cryptography — it’s scheduling. The two deadlines are offset by exactly one claim-window, so the only strategy that ever gets you the other side’s coins is… completing the trade. The word “atomic” in atomic swap means exactly this: either both legs happen, or neither does. There is no intermediate state where one party holds both assets.

Either both legs of the swap execute, or neither does. There is no state of the world in which one side ends up with both assets. That single guarantee replaces the escrow agent, the exchange, and the trust.
Why “atomic”
the protocol’s one guarantee
One Secret, Two Clocks, No Middleman: How Atomic Swaps Work
Peccando, CC0, via Wikimedia Commons

The Fine Print

The protocol is trustless, not free. Four catches, in ascending order of how much they’ve mattered in practice:

  • Both chains must speak the same hash. Bitcoin uses SHA-256; a chain that doesn’t can’t share a lock with it.
  • Both chains need the right scripting. HTLCs require conditional spending — hashlock plus timelock. Chains without expressive scripts can’t host their side.
  • Both parties must be online. The claim windows are real deadlines. Go offline for a day at the wrong moment and your safety margin evaporates. Software can watch for you, but that’s infrastructure you’re running or trusting.
  • The negotiation happens off-chain. Price discovery — who agrees to what rate — is outside the protocol. You found your counterparty in 2017 the same way you’d find someone to buy your couch: chat rooms and forums.

So Why Did Bridges Win?

This is where the case review turns uncomfortable. On paper, atomic swaps dominate: no custodian, no wrapped assets, no validator set to bribe, no $600-million Ronin-style honeypot. In practice, the industry’s cross-chain volume flows overwhelmingly through bridges and centralized exchanges. Why?

Because the four catches above are all UX problems, and UX wins. Bridges let you trade anytime, against pooled liquidity, with a single click and no counterparty to find. The 2017-style atomic swap needs a willing partner, both parties watching clocks, and fees on two chains. The market chose convenience over trustlessness — and then paid for that choice, repeatedly, every time a bridge got drained.

The idea didn’t die, though. It moved. The hash time-locked contract inside an atomic swap is the same primitive that routes payments through the Lightning Network — every multi-hop Lightning payment is a chain of hashlocks and timelocks clicking shut in sequence. And newer research (adaptor signatures built on Schnorr) is aimed at the privacy leak: today’s on-chain swap reveals the two legs and links the addresses; the newer schemes hide the linkage. The trustless path never closed. It just stopped being the cheapest one to click.

So here’s the question I’d leave you with. If a way to trade across chains without trusting anyone has existed since 2017 — and the custodial shortcuts built on top of it keep getting robbed — then what exactly are we paying the convenience premium for?

(The End)

Blockchain

12 Hashes Prove 4,000 Transactions: How the Merkle Tree Works

2026-10-12 2:33:38

Blockchain

Your Seed Phrase Never Left the Screen. That's How It Was Stolen.

2026-10-15 2:55:03

❯
Profile
Cart
Coupons
Search