MASTERING-BITCOIN

Cheat and Lose Everything: The Self-Enforcing Trick Behind Lightning Channels

IKey Formulas & Facts

Formula / Fact Name Description
N=2bN = 2^{b} State capacity Number of states a bb-bit index can label
248=281,474,976,710,6562^{48} = 281{,}474{,}976{,}710{,}656 Lightning index The 48-bit counter labeling every channel state
2-of-2 multisig Funding lock Funds move only when both parties sign
CSV delay (e.g. 1,000 blocks) Relative timelock The broadcaster's output must wait this many blocks

Core principle: The broadcaster always waits. Closing the channel is mildly costly to whoever does it — and broadcasting a revoked state is financial suicide.

IIInteractive Visualizations

Visualization 1: Updating the Channel Balance

Hitesh and Irene start with a balanced channel: 5 BTC each, 10 BTC total locked in a 2-of-2 multisig. Every time Irene pays Hitesh, they create a new state and revoke the old one.

Conceptual question: As payments flow, how does the channel balance shift — and why does revoking the old state matter to whoever used to hold more coins?

⚙ interactive visualization — coming to this page format soon

Notice: The two balances always sum to 10 BTC — value is conserved. When Irene pays Hitesh, her balance drops below the old state's value. That makes the old state attractive to her: she once held more coins.

Reflect: If the old (higher-balance) state were still usable, Irene could rewind to it and steal back coins. This is exactly why the old state must be made dangerous to broadcast — the job of the revocation key.

Visualization 2: The Penalty Window

Punishment is not automatic. When a cheater broadcasts a revoked state, their own output is locked behind a CSV relative timelock. The honest party (or their watchtower) must broadcast the penalty transaction before that delay expires.

Conceptual question: How does the CSV delay create a window of time, and what happens if the honest party reacts too slowly?

⚙ interactive visualization — coming to this page format soon

Notice: The penalty succeeds only when the reaction time is less than the CSV delay. A larger CSV delay gives the honest party a wider safety window — but also makes honest closes slower.

Reflect: Because vigilance is required, watchtower services exist: third parties you pay to watch the chain and fire the penalty while you sleep. The blockchain itself never polices cheaters for you.

Visualization 3: Why 48 Bits = Effectively Unlimited

Old timelock channels had a hard lifetime ceiling on the number of updates. Revocable channels remove that ceiling: states are no longer sequenced in time, just labeled by a 48-bit index counter.

Conceptual question: How fast does the number of possible states grow as we add bits to the index?

⚙ interactive visualization — coming to this page format soon

Notice: The state count grows exponentially — each added bit doubles capacity. At 48 bits you reach 281,474,976,710,656 states.

Reflect: A single channel can absorb that many updates and stay open indefinitely. Cheating is punishable, so old states no longer need to be ordered in time — they just need to be revoked and made dangerous.

IIIQuiz Questions

Question 1

Lightning uses a 48-bit index to label every channel state. How many distinct states can a 48-bit counter represent?

(Recall: N=2bN = 2^{b}.)

Correct! 2^48 = 281,474,976,710,656 states.

Not quite. The capacity is 2 raised to the power of the bit count, not a multiple of it.

Show solution

Solution:

A bb-bit counter can represent 2b2^{b} distinct values: N=248=281,474,976,710,656N = 2^{48} = 281{,}474{,}976{,}710{,}656

That is over 281 trillion states — enough that a channel can stay open essentially forever.

Question 2

In an asymmetric commitment, when a party broadcasts their own commitment transaction to close the channel, whose output is delayed by the CSV relative timelock?

Correct! The broadcaster always waits.

Not quite. Remember the principle: the broadcaster is the one whose output sits behind the timelock.

Show solution

Solution:

Each party holds their own version of the closing transaction. In Hitesh's commitment, Irene is paid immediately while Hitesh must wait 1,000 blocks. Irene's commitment is the mirror image.

So whoever broadcasts is the one who waits. This makes closing mildly costly to the initiator — and, crucially, it leaves the broadcaster's funds exposed long enough for the penalty branch to act if the state was revoked.

Question 3

True or False: Once a state is revoked, the Bitcoin network automatically punishes anyone who broadcasts that old state.

Correct! Someone must actively watch the chain and fire the penalty in time.

Not quite. The protocol makes cheating punishable, but the honest party must act within the timelock window.

Show solution

Solution: False.

Punishment is not automatic. The blockchain does not police cheaters. If a revoked state is broadcast, nothing happens unless the honest party (or a watchtower acting for them) notices and broadcasts the penalty transaction within the CSV window.

Miss the window, and the cheater's delayed output matures and they escape with the stolen funds. This vigilance requirement is exactly why watchtower services exist.

Question 4

The channel moves from State 1 (5 BTC / 5 BTC) to State 2 (7 BTC for Hitesh, 3 BTC for Irene), and they exchange revocation secrets for State 1. Later, Irene cheats by broadcasting the revoked State 1, where she held 5 BTC.

Assuming Hitesh reacts within the CSV window, what is the outcome?

Correct! Cheating turns into total loss — the self-enforcing penalty.

Not quite. The revoked state is still a valid transaction, but the revocation key lets the honest party take the entire balance.

Show solution

Solution:

When Irene revoked State 1, she handed Hitesh her half of the revocation secret. Hitesh now holds both halves and can reconstruct the full revocation key for that dead state.

If Irene broadcasts State 1:

  • Her own output sits behind the 1,000-block CSV delay (the slow ELSE branch).
  • Hitesh holds the complete revocation key, arming the instant IF branch.

Hitesh triggers the IF branch and seizes all 10 BTC before Irene's output matures. Irene tried to steal 2 BTC and lost everything — broadcasting an old state is financial suicide.

IVSummary

Lightning channels rest on asymmetric revocable commitments with relative timelocks:

Bitcoin's permanence wasn't bypassed — it was weaponized. The transaction you can never delete becomes the very tool that enforces honesty.

Solved: 0 / 4