HTLCs (Hash Time-Locked Contracts) The atomicity primitive that makes Lightning routing work. An HTLC is "claimable with preimage such that hash(r) = H, OR refundable after CLTV expires". Lifecycle Sender → first hop The onion contains routing data for Bob to forward. Forward chain Bob receives, peels onion, sees instructions to forward to Carol: Continues until destination Dave (final hop, onion is empty payload). Settlement (cooperative) Dave reveals preimage : Each hop earns its fee (held in the HTLC amount). Settlement (failed) Failure encryption uses ChaCha20 with onion shared secrets, h…