An HTLC is a contract that escrows funds with a hashlock and a timelock, enabling trust-minimized atomic payments across channels or chains.
An HTLC escrows funds such that they can be claimed by presenting the preimage of a known hash (hashlock) before a deadline (timelock). If the deadline passes without reveal, funds can be refunded. This primitive enables atomicity: either both sides complete, or both are refunded.
"In an atomic swap, Alice sends BCH to an HTLC locked by Bob's secret; Bob reveals the secret to claim BCH and proves it to Alice on the other chain."
"Payment channels use HTLCs to route multi-hop payments; intermediaries are paid only if the final recipient reveals the preimage."
The sender creates a contract with conditions: a hash H, a recipient who can spend with preimage x where H=hash(x) before time T, and a refund path to the sender after T. Timelocks can be absolute (CLTV) or relative (CSV).
"Using CLTV, the refund becomes valid at a specific block height; CSV requires waiting a relative number of blocks."
"Revealing the preimage on-chain allows all counterparties to claim their HTLCs in a routed payment."
Correctness depends on secure hash functions and synchronized timelocks across chains or channels. Attack considerations include fee spikes, mempool congestion, and adversarial timing. Conservative timelock deltas and fee bumping strategies help mitigate risks.
"If the refund timelock is too short, a congested mempool may prevent broadcasting the refund in time."
"Use chain-specific safety margins when constructing cross-chain HTLCs to account for different block times and reorg risk."
All terms and definitions may update as the Cryptionary improves.