BitSleuth
Back to Glossary
Advanced Bitcoin

What Is an HTLC (Hashed Timelock Contract)?

A Hashed Timelock Contract (HTLC) is a type of Bitcoin script that enables conditional payments based on cryptographic proof and time constraints. HTLCs are the fundamental building block of the Lightning Network, allowing trustless multi-hop payment routing.

Two Spending Conditions

An HTLC locks funds that can be spent in two ways: (1) the recipient reveals a secret preimage (hash lock), or (2) after a timeout, the sender can reclaim the funds (time lock). This creates atomic, trustless payment chains.

How HTLCs Work

Payment Routing

HTLCs enable payments to route through intermediate nodes. Each hop uses an HTLC with the same hash but decreasing timeouts. When the final recipient reveals the preimage, all intermediate nodes can claim their funds.

Safety Guarantees

The timelock ensures that if a payment fails, funds aren't stuck forever. Using CLTV and CSV, HTLCs provide strong guarantees that either the payment completes or funds return to the sender.

HTLCs combine cryptographic hash functions with Bitcoin's scripting capabilities to create trustless conditional payments. They're essential for Lightning's security model and enable features like atomic swaps between different cryptocurrencies.

Quick Facts

  • Combines hash locks and time locks
  • Enables trustless cross-chain swaps
  • Core primitive of Lightning Network

Related Terms