Glossary

HTLC-Success Transaction

An HTLC-success transaction claims funds from an HTLC output by revealing the payment hash preimage on-chain.

Key Takeaways

  • An HTLC-success transaction is a pre-signed, second-stage Bitcoin transaction that spends a received HTLC output from a commitment transaction by revealing the payment preimage on-chain.
  • It is used during a force close when the channel counterparty broadcasts a commitment transaction containing an HTLC that the recipient has already fulfilled. The recipient proves they know the preimage and claims the funds.
  • The output of an HTLC-success transaction is subject to a relative timelock (to_self_delay) before the claimer can spend it, giving the counterparty time to broadcast a justice transaction if the commitment was revoked.

What Is an HTLC-Success Transaction?

An HTLC-success transaction is one of two second-stage transactions defined in BOLT 3 (the Lightning Network's transaction specification) for resolving hash time-locked contract outputs that appear on a commitment transaction. When a channel is force-closed while in-flight payments exist, those payments become HTLC outputs on the broadcast commitment transaction. The party that knows the payment preimage can claim those funds by broadcasting an HTLC-success transaction.

Its counterpart is the HTLC-timeout transaction, which lets the HTLC offerer (the sender side of the payment) reclaim funds after the HTLC's expiry time passes. Together, these two transactions represent the two possible outcomes for any in-flight HTLC that must be resolved on-chain: the recipient claims via success (preimage), or the sender reclaims via timeout (expiry).

The reason HTLC outputs require a separate second-stage transaction rather than being spent directly is the Lightning Network's revocation mechanism. In the Poon-Dryja channel construction, every HTLC spend must include a revocation path so the counterparty can penalize the broadcast of an outdated commitment. This two-stage design makes that possible without increasing the minimum HTLC timelock at every routing hop.

How It Works

To understand the HTLC-success transaction, it helps to follow the lifecycle of an in-flight payment during a force close. Consider a channel between Alice and Bob where Bob has forwarded a payment to Alice. Alice knows the preimage because she is the final recipient (or she has already received it from a downstream hop).

  1. Bob broadcasts his commitment transaction on-chain. This commitment includes a "received HTLC" output from Alice's perspective: an output locked to both a preimage path and a timeout path.
  2. Alice sees the commitment transaction confirm on-chain and identifies the HTLC output she can claim.
  3. Alice broadcasts her pre-signed HTLC-success transaction, providing the payment preimage in the witness data along with the required signatures.
  4. The HTLC-success transaction confirms, and its output pays Alice through a script that enforces a relative timelock (to_self_delay, typically 144 blocks or about one day) before she can spend the funds freely.
  5. After the to_self_delay period passes, Alice sweeps the output to her wallet.

Witness Structure

The HTLC-success transaction's input witness proves that the spender knows the preimage and has the required signatures. Per BOLT 3, the witness for spending a received HTLC output via the success path is:

# HTLC-success witness (received HTLC output)
0                    # Placeholder for OP_CHECKMULTISIG bug
<remotehtlcsig>      # Remote party's pre-signed HTLC signature
<localhtlcsig>       # Local party's signature
<payment_preimage>   # The 32-byte preimage that hashes to the payment hash

The remote party's signature (remotehtlcsig) is provided during the normal channel update protocol, before any force close occurs. Each time a new HTLC is added to the channel, both parties exchange signatures for the corresponding HTLC-success and HTLC-timeout transactions. This pre-signing ensures that either party can resolve HTLCs unilaterally if the channel is force-closed.

Output Script and Revocation

The output of the HTLC-success transaction does not pay directly to the claimer's key. Instead, it uses the same script template as the commitment transaction's to_local output:

OP_IF
    <revocationpubkey>
OP_ELSE
    <to_self_delay>
    OP_CHECKSEQUENCEVERIFY
    OP_DROP
    <local_delayedpubkey>
OP_ENDIF
OP_CHECKSIG

This script has two spending paths. The normal path requires waiting to_self_delay blocks (enforced by OP_CHECKSEQUENCEVERIFY) before the local party can spend with their delayed key. The revocation path lets the counterparty immediately claim the output using the revocation key if the HTLC-success transaction was built on top of a revoked commitment.

HTLC-Success vs. HTLC-Timeout

The two second-stage HTLC transactions are structurally almost identical. The critical differences are:

PropertyHTLC-SuccessHTLC-Timeout
Who uses itHTLC recipient (knows preimage)HTLC offerer (sent the payment)
Witness includesPayment preimageEmpty preimage field (zero-length)
TimelockNone (can broadcast immediately)CLTV lock until HTLC expiry height
PurposeClaim received fundsReclaim offered funds after timeout

The HTLC-success transaction can be broadcast as soon as the commitment transaction confirms because the preimage itself proves the payment was fulfilled. The HTLC-timeout transaction, by contrast, must wait until the HTLC's CLTV expiry passes, ensuring the recipient has adequate time to claim with the preimage first.

Anchor Outputs and Fee Bumping

In channels using anchor outputs, the HTLC-success transaction is designed to support fee bumping. The remote party's pre-signed HTLC signature uses SIGHASH_SINGLE|ANYONECANPAY, which allows the broadcaster to attach additional inputs and outputs to increase the transaction's fee rate via CPFP or by adding fee inputs directly.

This is critical during periods of high on-chain fee market activity. Without the ability to fee bump, an HTLC-success transaction signed at a low fee rate might not confirm before the HTLC's timeout, allowing the offerer to claim the funds with an HTLC-timeout transaction instead. The anchor output design, combined with v3 transaction relay policies and package relay, helps ensure that time-sensitive HTLC-success transactions can always compete for block space. For a deeper look at how these mechanisms interact, see the research article on Lightning v3 transactions and package relay.

Preimage Extraction

One of the most important properties of the HTLC-success transaction is that it reveals the payment preimage on the Bitcoin blockchain. BOLT 5 requires that when a node observes an HTLC output being spent with a preimage, it must extract that preimage from the transaction's witness data. This is essential for multi-hop payment security.

Consider a routing node that forwarded a payment: it has an incoming HTLC on one channel and an outgoing HTLC on another. If the downstream channel force-closes and the next hop claims the outgoing HTLC with an HTLC-success transaction, the routing node must learn the preimage from that on-chain transaction so it can settle the incoming HTLC (either off-chain or via its own HTLC-success transaction). Without this preimage extraction, the routing node would lose funds: paying out on the outgoing side without being able to claim on the incoming side.

This is why watchtowers and channel monitors must continuously watch the blockchain for HTLC spends. Missing a preimage revelation could result in permanent loss of funds for a routing node.

Why It Matters

The HTLC-success transaction is fundamental to the security guarantees of the Lightning Network. Without it, force-closing a channel with pending payments would mean either losing those funds or relying on trust. The ability to claim HTLCs on-chain with the preimage ensures that multi-hop payments remain trustless even when channels break down.

For payment infrastructure built on Lightning, understanding HTLC resolution mechanics matters for capacity planning, risk management, and fee estimation. Protocols like Spark take a different approach to off-chain payments that avoids the complexity of managing HTLC-success and HTLC-timeout transactions entirely by using statechain transfers and cooperative signing rather than payment channels. This eliminates the need for on-chain HTLC resolution and the associated costs and risks. For a comparison of these approaches, see the research on what is Spark.

Risks and Considerations

Race Conditions with HTLC-Timeout

Near the HTLC expiry height, a race can develop between the HTLC-success and HTLC-timeout transactions. If both are broadcast close to the expiry block, miners decide which confirms based on fee rate. A well-funded attacker could use replace-by-fee to outbid the HTLC-success transaction with a higher-fee HTLC-timeout, a technique sometimes called replacement cycling. This risk is mitigated by broadcasting the HTLC-success transaction well before the timeout and by using anchor outputs for fee bumping.

On-Chain Fees

Each HTLC-success transaction consumes block space and requires mining fees. During a force close with many pending HTLCs, the total on-chain cost can be substantial. The claimer must pay for both the HTLC-success transaction itself and the subsequent sweep of the delayed output after to_self_delay expires. In high-fee environments, small HTLCs may cost more to claim on-chain than they are worth, making them economically unviable to resolve.

Revocation Risk

If a node broadcasts an HTLC-success transaction built on a revoked commitment, the counterparty can claim the output immediately using the revocation key, taking the full amount as a penalty. This is the same penalty mechanism that protects against broadcasting old commitment states.

Monitoring Requirements

Nodes must monitor the blockchain continuously to detect when their counterparty broadcasts a commitment transaction with HTLC outputs. If a node goes offline and misses the commitment broadcast, it may fail to claim its HTLCs before the timeout expires. Delegating this monitoring to a watchtower can mitigate the risk, but requires sharing preimages or pre-signed transactions with the watchtower service.

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.