Skip to main content
£0.00 0

Basket

No products in the basket.

ASIC mining articles and advice

BIP 199 HTLC Transactions: Closed Script Template

BIP 199 guide covering its closed HTLC template, hash preimages, buyer refunds, absolute and relative timeouts, branch validation and operational risks.

BIP 199 HTLC guide cover

This guide explains BIP 199 HTLC in plain English. It covers the problem behind the BIP, why it matters and whether the proposal is part of Bitcoin today.

TL;DR

  • What it is: BIP 199 specified a general Hashed Time-Locked Contract script in which a seller could spend by revealing a hash preimage and signature, while a buyer could refund after a timeout. It allowed SHA-256 or HASH160 and absolute or relative lock-time opcodes.
  • Why it matters: BIP 199 described the essential preimage-or-timeout pattern but is a closed template, not a complete modern payment protocol. Safe use requires exact script, timing, fee and monitoring rules from the deployed application.
  • Current position: The BIP is Closed; real payment-channel and swap systems use protocol-specific scripts and deployed conventions that must be verified independently.

BIP 199 HTLC in simple English

BIP 199 HTLC: BIP 199 did not standardise all HTLC applications. Lightning, atomic swaps and wallet contracts define extra key, timeout, revocation and transaction rules.

Simple example

A miner is checking BIP 199 HTLC. The refund branch enforces a lock condition before checking the buyer signature. Similar-looking scripts are not interchangeable, and software should not claim BIP 199 compliance as a complete protocol audit.

Key terms in plain English

BIP:
Bitcoin Improvement Proposal: a document describing a proposed rule, standard or process. Its status must be checked separately.
Node:
A computer running Bitcoin software that checks data and communicates with other peers.

Two spending branches

The success branch checks a supplied preimage against the committed digest and then checks the seller signature. The refund branch enforces a lock condition before checking the buyer signature. Branch selection, stack order and final equality checks are part of the exact security model.

Hash choice and secret quality

A preimage must be unpredictable and generated with enough entropy. HASH160 and SHA-256 produce different digest sizes and security properties. Reusing a secret across contracts links them and revealing it in one place can unlock every compatible contract elsewhere.

Absolute and relative timeouts

CHECKLOCKTIMEVERIFY uses an absolute height or time, while CHECKSEQUENCEVERIFY uses age relative to confirmation under BIP 68 semantics. Units, transaction version, sequence disable flags and median-time-past rules matter. Off-by-one and height-versus-time errors can strand refunds.

BIP 199 HTLC technical diagram
Absolute and relative timeouts: the fields, validation boundary and operational evidence that implementations need to agree.

Transaction construction

The spending transaction must provide the correct selector, preimage or empty placeholder, signature and redeem or witness script in the expected order. Fee changes and signature commitments can affect pre-signed refunds. Test the exact script container and sighash, not just readable assembly.

Monitoring and race conditions

The buyer needs the refund path after timeout, while the seller’s preimage spend may reveal the secret near the boundary. Watchers must detect confirmations, reorganisations and competing spends. A timeout is eligibility, not guaranteed inclusion, and fee reserves must support timely settlement.

Closed status and modern protocols

BIP 199 did not standardise all HTLC applications. Lightning, atomic swaps and wallet contracts define extra key, timeout, revocation and transaction rules. Similar-looking scripts are not interchangeable, and software should not claim BIP 199 compliance as a complete protocol audit.

How specialists test it

Developers test the proposal with made-up data on an isolated test network. They check normal cases and deliberately invalid cases. Different implementations should reach the same result before anyone relies on the proposal.

Frequently asked questions

What is the main point of BIP 199 HTLC?

BIP 199 HTLC: BIP 199 did not standardise all HTLC applications. Lightning, atomic swaps and wallet contracts define extra key, timeout, revocation and transaction rules.

For BIP 199 HTLC, what should a beginner know about two spending branches?

The success branch checks a supplied preimage against the committed digest and then checks the seller signature.

For BIP 199 HTLC, what should a beginner know about hash choice and secret quality?

A preimage must be unpredictable and generated with enough entropy. HASH160 and SHA-256 produce different digest sizes and security properties.

For BIP 199 HTLC, what should a beginner know about absolute and relative timeouts?

CHECKLOCKTIMEVERIFY uses an absolute height or time, while CHECKSEQUENCEVERIFY uses age relative to confirmation under BIP 68 semantics.

Conclusion

BIP 199 described the essential preimage-or-timeout pattern but is a closed template, not a complete modern payment protocol. Safe use requires exact script, timing, fee and monitoring rules from the deployed application.

Primary sources

Check the current specification status and the documentation for the exact implementation you operate before moving production funds or changing a mining node.

ASIC MINER PICKS

Recommended ASIC Mining Hardware

Compare three of our highest ranked ASIC miners currently available, with live product details and pricing.
Browse all ASIC miners
MORE MINING ADVICE

More ASIC Mining Articles

Read practical advice about choosing hardware, calculating electricity costs, setting up miners, hosting and maintenance.
MINER COMMUNITY

Join the ASIC Mining Discussion

Ask a question or share what has worked for you. Your experience may help another miner make a better decision.

Members can read and join the discussion

Log in to read comments from other miners. Create a free account if you would like to ask a question or share your experience.

Log in to read comments Register to join the discussion

Membership helps us protect the discussion from spam and keep answers useful.

ASIC MINING SUPPORT

Need Help Choosing an ASIC Miner?

Tell us what you want to mine, your electricity cost and where the machine will run. We can help you compare hardware, power requirements, hosting and repairs.
Contact our mining team
Browse ASIC miners