Lightning Network Interactive Demo

Learn how Bitcoin's instant payment layer works

What is the Lightning Network?

The Lightning Network is Bitcoin's instant payment layer. Instead of waiting 10 minutes for each Bitcoin transaction, Lightning payments settle in milliseconds with fees less than a penny.

Key Benefits:
  • Instant payments (milliseconds, not minutes)
  • Tiny fees (fraction of a cent)
  • Still Bitcoin (backed by real BTC on-chain)
  • Microtransactions (send $0.01 if you want)

Payment Channels: The Foundation

A payment channel is like a Bitcoin bank account shared between two people. They lock up Bitcoin on-chain, then send it back and forth instantly off-chain.

Alice Bob Payment Channel

500,000
Alice (sats)
500,000
Bob (sats)

How It Works:

1. Open channel with 1M sats total
2. Each starts with 500K sats
3. Send payments instantly
4. Close channel to settle on-chain

Controls

🤔 Why is Lightning faster than Bitcoin?
Lightning payments happen off-chain (outside the blockchain). Only the channel opening and closing are recorded on Bitcoin's blockchain. Everything in between is instant peer-to-peer updates!
🤔 What happens if Alice runs out of balance?
Alice can't send more than she has in the channel. To receive more, someone needs to send her payment, or she needs to close the channel and open a new one with more funds.

Multi-Hop Routing: The Power of Lightning

You don't need a direct channel with everyone! Lightning can route payments through intermediate nodes, just like the internet routes data through routers.

Example: Alice → Carol

Alice wants to pay Carol, but doesn't have a direct channel. No problem!
Route: Alice → Bob → Carol
Payment goes through Bob's channel, and he forwards it to Carol (earning a small fee).

Payment

0
Sent (sats)
0
Fees (sats)
2
Hops

📋 Transaction Log

🤔 How does Bob know to forward the payment to Carol?
Lightning uses onion routing (like Tor). Alice encrypts the payment path in layers. Each node can only see the previous and next hop, not the full route. Bob knows to forward to Carol because that's in his layer of the "onion".
🤔 What if Bob tries to steal the payment?
Lightning uses HTLCs (Hash Time-Locked Contracts). Bob can only claim the payment if he has the secret (preimage). He only gets that by forwarding to Carol. If he doesn't forward, he can't claim the funds, and they eventually time out back to Alice.

🔬 HTLCs: How Lightning Ensures Atomicity

Hash Time-Locked Contracts (HTLCs) are the cryptographic mechanism that makes multi-hop payments trustless.

⚠️ The Problem: How do you ensure all intermediate nodes forward the payment correctly without trust?
✅ The Solution: HTLCs
  1. Carol generates a secret (preimage) and sends Alice its hash
  2. Alice creates HTLC: "Bob gets paid IF he reveals the preimage within 24 hours"
  3. Bob creates HTLC with Carol: "Carol gets paid IF she reveals the preimage within 12 hours"
  4. Carol reveals preimage to claim from Bob
  5. Bob uses same preimage to claim from Alice
  6. Result: Either everyone gets paid, or no one does (atomic)
100%
Success Rate
0.02%
Avg Fee Rate
5M
Network Liquidity
250ms
Avg Latency

📋 HTLC Execution Log

Technical Details:

  • Hash Function: SHA256 (same as Bitcoin)
  • Preimage Size: 32 bytes (256 bits of entropy)
  • Time Locks: CLTV (CheckLockTimeVerify) for expiration
  • Routing Protocol: Onion routing with Sphinx packet format
  • Penalty Mechanism: Revocation keys for old channel states
🤔 Why do HTLCs have decreasing timelocks?
Timelocks decrease along the route (24h → 12h → 6h) to ensure intermediaries have time to claim their funds before their own HTLCs expire. This prevents them from being stuck in a state where they've paid out but can't claim their incoming HTLC.
🤔 What's the channel reserve requirement?
Each party must keep a minimum balance (typically 1% of channel capacity) as a channel reserve. This ensures there's always something at stake to penalize cheating (broadcasting old channel states). Without it, the penalty mechanism wouldn't work.

What's Next?

Ready to try Lightning yourself?

  • Download a Lightning wallet (Phoenix, Muun, or Wallet of Satoshi)
  • Practice on testnet first (free fake Bitcoin)
  • Start with small amounts ($5-10)
  • Try buying coffee or tipping content creators

Dive deeper into Lightning:

  • Run your own Lightning node (Umbrel, RaspiBlitz, Start9)
  • Open channels with well-connected nodes
  • Learn about liquidity management and channel balancing
  • Explore routing node economics (earning fees)

Advanced Lightning topics:

  • Implement Lightning with LND, CLN, or Eclair
  • Build Lightning apps using LNURL or WebLN
  • Study channel factories and multi-party channels (Eltoo)
  • Explore Taproot channels and PTLCs (Point Time-Locked Contracts)
  • Contribute to Lightning protocol development (BOLTs)