<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.bitcoin.it/w/index.php?action=history&amp;feed=atom&amp;title=BIP_0199</id>
	<title>BIP 0199 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://en.bitcoin.it/w/index.php?action=history&amp;feed=atom&amp;title=BIP_0199"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=BIP_0199&amp;action=history"/>
	<updated>2026-05-13T23:53:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=BIP_0199&amp;diff=66758&amp;oldid=prev</id>
		<title>934: Update BIP text with latest version from https://github.com/bitcoin/bips/blob/b5723035e23896d0/bip-0199.mediawiki</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=BIP_0199&amp;diff=66758&amp;oldid=prev"/>
		<updated>2019-09-24T17:58:33Z</updated>

		<summary type="html">&lt;p&gt;Update BIP text with latest version from https://github.com/bitcoin/bips/blob/b5723035e23896d0/bip-0199.mediawiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{bip}}&lt;br /&gt;
{{BipMoved|bip-0199.mediawiki}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  BIP: 199&lt;br /&gt;
  Layer: Applications&lt;br /&gt;
  Title: Hashed Time-Locked Contract transactions&lt;br /&gt;
  Author: Sean Bowe &amp;lt;sean@z.cash&amp;gt;&lt;br /&gt;
          Daira Hopwood &amp;lt;daira@z.cash&amp;gt;&lt;br /&gt;
  Comments-Summary: No comments yet.&lt;br /&gt;
  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0199&lt;br /&gt;
  Status: Draft&lt;br /&gt;
  Type: Standards Track&lt;br /&gt;
  Created: 2017-03-27&lt;br /&gt;
  License: BSD-3-Clause&lt;br /&gt;
           CC0-1.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Abstract==&lt;br /&gt;
&lt;br /&gt;
This BIP describes a script for generalized off-chain contract negotiation.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
A Hashed Time-Locked Contract (HTLC) is a script that permits a designated party (the &amp;quot;seller&amp;quot;) to spend funds by disclosing the preimage of a hash.  It also permits &lt;br /&gt;
a second party (the &amp;quot;buyer&amp;quot;) to spend the funds after a timeout is reached, in a refund situation.&lt;br /&gt;
&lt;br /&gt;
The script takes the following form:&lt;br /&gt;
&lt;br /&gt;
    OP_IF&lt;br /&gt;
        [HASHOP] &amp;lt;digest&amp;gt; OP_EQUALVERIFY OP_DUP OP_HASH160 &amp;lt;seller pubkey hash&amp;gt;            &lt;br /&gt;
    OP_ELSE&lt;br /&gt;
        &amp;lt;num&amp;gt; [TIMEOUTOP] OP_DROP OP_DUP OP_HASH160 &amp;lt;buyer pubkey hash&amp;gt;&lt;br /&gt;
    OP_ENDIF&lt;br /&gt;
    OP_EQUALVERIFY&lt;br /&gt;
    OP_CHECKSIG&lt;br /&gt;
&lt;br /&gt;
[HASHOP] is either OP_SHA256 or OP_HASH160.&lt;br /&gt;
&lt;br /&gt;
[TIMEOUTOP] is either OP_CHECKSEQUENCEVERIFY or OP_CHECKLOCKTIMEVERIFY.&lt;br /&gt;
&lt;br /&gt;
===Interaction===&lt;br /&gt;
&lt;br /&gt;
* Victor (the &amp;quot;buyer&amp;quot;) and Peggy (the &amp;quot;seller&amp;quot;) exchange public keys and mutually agree upon a timeout threshold.  Peggy provides a hash digest.  Both parties can now construct the script and P2SH address for the HTLC.&lt;br /&gt;
* Victor sends funds to the P2SH address.&lt;br /&gt;
* Either:&lt;br /&gt;
** Peggy spends the funds, and in doing so, reveals the preimage to Victor in the transaction; OR&lt;br /&gt;
** Victor recovers the funds after the timeout threshold.&lt;br /&gt;
&lt;br /&gt;
Victor is interested in a lower timeout to reduce the amount of time that his funds are encumbered in the event that Peggy does not reveal the preimage.  Peggy is &lt;br /&gt;
interested in a higher timeout to reduce the risk that she is unable to spend the funds before the threshold, or worse, that her transaction spending the funds does &lt;br /&gt;
not enter the blockchain before Victor&amp;#039;s but does reveal the preimage to Victor anyway.&lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
In many off-chain protocols, secret disclosure is used as part of a settlement mechanism.  In some others, the secrets themselves are valuable.  HTLC transactions are &lt;br /&gt;
a safe and cheap method of exchanging secrets for money over the blockchain, due to the ability to recover funds from an uncooperative counterparty, and the &lt;br /&gt;
opportunity that the possessor of a secret has to receive the funds before such a refund can occur.&lt;br /&gt;
&lt;br /&gt;
===Lightning network===&lt;br /&gt;
&lt;br /&gt;
In the lightning network, HTLC scripts are used to perform atomic swaps between payment channels.&lt;br /&gt;
&lt;br /&gt;
Alice constructs K and hashes it to produce L.  She sends an HTLC payment to Bob for the preimage of L.  Bob sends an HTLC payment to Carol for the same preimage and &lt;br /&gt;
amount.  Only when Alice releases the preimage K does any exchange of value occur, and because the secret is divulged for each hop, all parties are compensated.  If &lt;br /&gt;
at any point some parties become uncooperative, the process can be aborted via the refund conditions.&lt;br /&gt;
&lt;br /&gt;
===Zero-knowledge contingent payments===&lt;br /&gt;
&lt;br /&gt;
Various practical zero-knowledge proving systems exist which can be used to guarantee that a hash preimage derives valuable information.  As an example, a &lt;br /&gt;
zero-knowledge proof can be used to prove that a hash preimage acts as a decryption key for an encrypted sudoku puzzle solution.  (See &lt;br /&gt;
[https://github.com/zcash/pay-to-sudoku pay-to-sudoku] for a concrete example of such a protocol.)&lt;br /&gt;
&lt;br /&gt;
HTLC transactions can be used to exchange such decryption keys for money without risk, and they do not require large or expensive-to-validate transactions.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
&lt;br /&gt;
https://github.com/bitcoin/bitcoin/pull/7601&lt;br /&gt;
&lt;br /&gt;
==Copyright==&lt;br /&gt;
&lt;br /&gt;
This document is dual licensed as BSD 3-clause, and Creative Commons CC0 1.0 Universal.&lt;/div&gt;</summary>
		<author><name>934</name></author>
	</entry>
</feed>