HTLC-Timeout Transaction
An HTLC-timeout transaction reclaims funds from an expired HTLC output when the payment hash preimage was not revealed.
Key Takeaways
- An HTLC-timeout transaction is a pre-signed, second-stage transaction that spends an offered HTLC output back to the offerer after the CLTV timelock expires, reclaiming funds when the recipient fails to reveal the payment preimage.
- It is pre-signed by the remote party when the HTLC is created, so the local node can broadcast it unilaterally during a force close without needing further cooperation.
- The output of the HTLC-timeout transaction includes a revocation path and a CSV delay (to_self_delay), giving the counterparty time to broadcast a justice transaction if the commitment was revoked.
What Is an HTLC-Timeout Transaction?
An HTLC-timeout transaction is a Bitcoin transaction defined in the Lightning Network's BOLT 3 specification that lets the offerer of an HTLC reclaim their funds when the recipient fails to present the preimage before the agreed-upon expiration height. It is one of two "second-stage" transactions that spend HTLC outputs from a commitment transaction: the other is the HTLC-success transaction, which the recipient uses to claim funds by revealing the preimage.
In a Lightning payment, the sender locks funds into an HTLC with two possible outcomes: the recipient claims the funds by presenting the correct preimage (the success path), or the sender recovers the funds after a timeout (the timeout path). The HTLC-timeout transaction implements this second outcome on-chain. Without it, funds locked in an expired HTLC would be stranded indefinitely on the commitment transaction.
How It Works
To understand the HTLC-timeout transaction, it helps to see where it fits in the lifecycle of a Lightning payment that goes to chain.
The Two-Stage Design
Lightning channels use the Poon-Dryja revocation mechanism, where each channel update produces a new commitment transaction that supersedes the previous one. The commitment transaction itself is not subject to a CSV (relative timelock) delay. Instead, revocation safety is enforced at the next level: the transactions that spend outputs from the commitment. This design is why HTLC outputs on a commitment transaction cannot be spent directly by the offerer after timeout. They must be spent through a second-stage HTLC-timeout transaction whose output carries a revocation key path and a CSV delay.
The sequence during a force close with a pending offered HTLC:
- The local node broadcasts its commitment transaction, which includes an offered HTLC output
- The commitment transaction confirms on-chain
- The local node waits until the HTLC's CLTV expiry height (an absolute block height) passes
- The local node broadcasts the HTLC-timeout transaction, spending the offered HTLC output
- After the HTLC-timeout transaction confirms, the output is subject to to_self_delay (a relative CSV lock, typically 144 blocks or more)
- Once the CSV delay passes, the local node can sweep the funds into its wallet
Pre-Signing and Unilateral Broadcast
The HTLC-timeout transaction requires signatures from both channel parties (a 2-of-2 multisig). However, the remote party pre-signs it at the time the HTLC is created. This means the local node holds a fully valid, pre-signed HTLC-timeout transaction and can broadcast it without needing any further cooperation from the remote node. This property is essential: a force close happens precisely when the remote node is unresponsive or uncooperative.
Timelock and Output Script
The HTLC-timeout transaction's nLockTime field is set to the HTLC's cltv_expiry value. The Bitcoin network will not accept the transaction into a block until this absolute block height has passed. This enforces the timeout condition at the protocol level.
The output of the HTLC-timeout transaction uses a script with two spending paths:
OP_IF
# Revocation path: counterparty can spend immediately
# if commitment was revoked
<revocationpubkey>
OP_ELSE
# Delayed path: offerer can spend after CSV delay
<to_self_delay>
OP_CHECKSEQUENCEVERIFY
OP_DROP
<local_delayedpubkey>
OP_ENDIF
OP_CHECKSIGThe revocation path allows the counterparty to claim funds immediately if the offerer published a revoked commitment transaction. The delayed path lets the offerer claim their refund after the to_self_delay period, giving the counterparty a window to detect and punish cheating via a penalty transaction.
Asymmetric Perspectives
HTLC outputs look different depending on whose commitment transaction was broadcast. On the local commitment, the offerer must use an HTLC-timeout transaction (second-stage) to reclaim funds. On the remote commitment, the offerer can spend the HTLC output directly after the CLTV expiry without a second-stage transaction, because the revocation delay is already enforced differently on the remote side.
Anchor Outputs and Fee Bumping
In the original Lightning channel design, the fee for the HTLC-timeout transaction was set at the time it was signed. This created a problem: if on-chain fees spiked between signing and broadcast, the pre-signed fee might be too low for the transaction to confirm before the timelock window closes.
Anchor outputs solve this by setting the HTLC-timeout transaction's fee to zero at signing time and attaching small anchor outputs to the commitment transaction. When the offerer needs to broadcast, they use CPFP (child-pays-for-parent) to add fees dynamically by spending an anchor output with a child transaction that pays the current market fee rate. This ensures the HTLC-timeout transaction can always confirm, regardless of fee conditions at broadcast time.
Modern implementations default to anchor-style channels. Core Lightning adopted anchor channels as the default, and LND's deadline-aware sweeper automatically manages fee bumping for HTLC-timeout transactions based on how close the CLTV delta deadline is.
HTLC-Timeout vs. HTLC-Success
The HTLC-timeout and HTLC-success transactions are complementary second-stage transactions, each representing one of the two possible outcomes for an HTLC:
| Property | HTLC-Timeout | HTLC-Success |
|---|---|---|
| Purpose | Refund funds to offerer | Claim funds for recipient |
| Condition | CLTV expiry passes, no preimage revealed | Valid preimage presented before expiry |
| Timelock | nLockTime = cltv_expiry | nLockTime = 0 (no absolute lock) |
| Witness | Both signatures, empty preimage placeholder | Both signatures, actual preimage |
| Output | Revocation + CSV-delayed to offerer | Revocation + CSV-delayed to recipient |
Both transactions share the same output script structure (revocation path plus CSV-delayed claim), ensuring revocation safety regardless of which outcome occurs. For a deeper look at how these transactions interact with fee markets and package relay, see the v3 transactions and package relay analysis.
Use Cases
Force Close Fund Recovery
The primary use case is recovering funds from expired HTLCs during a unilateral channel close. When a routing node forwards an HTLC and the downstream hop fails to settle before timeout, the routing node must reclaim those funds. The HTLC-timeout transaction is the mechanism that enables this recovery without cooperation from the counterparty.
Multi-Hop Payment Resolution
In a multi-hop payment, each hop has a decreasing CLTV expiry. If a payment fails midway through the route, each intermediate node uses HTLC-timeout transactions (or their off-chain equivalents) to cascade the failure back to the sender. The decreasing timeouts ensure each upstream hop can reclaim funds before its own timeout expires.
Routing Node Protection
Routing nodes are especially reliant on HTLC-timeout transactions. A routing node forwards funds downstream while holding an upstream HTLC. If the downstream node disappears without revealing the preimage, the routing node must go on-chain to recover via the HTLC-timeout path. Without reliable HTLC-timeout execution, routing nodes would bear unbounded risk of losing forwarded funds.
Risks and Considerations
Race Conditions with HTLC-Success
A critical risk arises when both the HTLC-timeout and HTLC-success transactions compete for the same HTLC output. If the recipient broadcasts an HTLC-success transaction (revealing the preimage) at nearly the same time the offerer broadcasts the HTLC-timeout, only one can confirm. If the HTLC-success confirms, the offerer loses those funds from their local commitment but should learn the preimage and use it to settle the upstream HTLC. The danger occurs when the offerer does not observe the preimage in time.
Fee Estimation Under Pressure
Even with anchor outputs, the offerer must have sufficient on-chain funds to fee-bump the HTLC-timeout transaction. A 2025 security disclosure (CVE-2025-27586) described scenarios where fee-bumping reserves could be exhausted through targeted attacks, potentially preventing timely broadcast of HTLC-timeout transactions. Node operators should monitor their fee-bumping reserves and configure appropriate limits.
Flood-and-Loot Attacks
The flood-and-loot attack exploits the HTLC-timeout mechanism by forcing many channels to close simultaneously. The attacker routes payments through a victim, force-closes channels, and tries to claim HTLCs with preimages before the victim's HTLC-timeout transactions confirm. High mempool congestion can delay HTLC-timeout confirmations, giving the attacker a window to steal funds. Mitigations include anchor output fee bumping and careful CLTV delta configuration.
On-Chain Costs
Each HTLC-timeout transaction requires a separate on-chain transaction with its own fees. In a force close involving multiple pending HTLCs, the total on-chain cost can be substantial. The offerer pays fees for the commitment transaction, each HTLC-timeout transaction, and the final sweep transaction. This multi-transaction resolution is one reason cooperative closes are preferred when possible, and why Layer 2 solutions like Spark avoid the per-channel on-chain footprint entirely by using a statechain-based architecture.
Revocation Window
The to_self_delay on the HTLC-timeout output exists specifically so the counterparty can punish a cheating offerer who broadcasts a revoked commitment. If the counterparty's watchtower is offline during this window, a cheating party could successfully sweep the HTLC-timeout output from an old state. Proper watchtower configuration mitigates this risk.
This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.