Definition
A Hashed Timelock Contract (HTLC) is the conditional payment primitive at the heart of every Lightning Network transaction. It locks funds against two conditions enforced by Bitcoin Script: a hashlock, which releases the money only when a secret value (the preimage) matching a known hash is revealed, and a timelock, which refunds the sender if that secret never appears before a deadline.
How HTLCs enable multi-hop payments
The recipient generates a random 32-byte preimage and shares only its SHA-256 hash inside the invoice. The sender constructs a chain of HTLCs across each channel on the route, all locked to that same hash. When the recipient claims the final HTLC by revealing the preimage, each intermediate routing node learns the secret and pulls payment from the hop before it. Either the whole payment settles or none of it does, giving Lightning its atomic, trustless character.
The timelock safety net
Each hop's timelock (expressed as a CLTV delta) decreases toward the destination, guaranteeing an upstream node always has time to react before its downstream HTLC can be reversed. If a route stalls, the timelock lets the sender reclaim funds on-chain without trusting any intermediary.
HTLCs depend on the payment channel structure and are forwarded using onion routing across routing nodes. The same hashlock idea underpins atomic swaps and submarine swaps.
In Simple Terms
A Hashed Timelock Contract (HTLC) is the conditional payment primitive at the heart of every Lightning Network transaction. It locks funds against two conditions enforced…
