Skip to content

Commit

Permalink
Edited 08_routing_htlcs.asciidoc with Atlas code editor
Browse files Browse the repository at this point in the history
  • Loading branch information
kristenORM committed Oct 28, 2021
1 parent a6dc5cc commit fe06a41
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions 08_routing_htlcs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ Dina generates this secret value +R+ from a random number generator.

The secret could then be committed to the contract by including the SHA-256 hash of the secret in the contract itself, as follows:

latexmath:[\(H = SHA-256(R)\)]
++++
<ul class="simplelist">
<li><em>H</em> = SHA-256(<em>R</em>)</li>
</ul>
++++

We call this hash of the payment's secret the _payment hash_.
The secret that "unlocks" the payment is called the _payment secret_.
Expand Down Expand Up @@ -348,7 +352,7 @@ In our gold coin example, Alice had a contract enforced by escrow like the one i
_Alice will reimburse Bob with 12 gold coins if you can show a valid message that hashes to:_ +0575...f6b3+. _Bob has 24 hours to show the secret after the contract was signed. If Bob does not provide the secret by this time, Alice's deposit will be refunded by the escrow service and the contract becomes invalid._
====

Let's see how we would implement this as an HTLC in Bitcoin Script. In <<received_htlc>> we see an HTLC Bitcoin Script as currently used in the Lightning Network. You can find this definition in https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#offered-htlc-outputs[BOLT3: Transactions]:
Let's see how we would implement this as an HTLC in Bitcoin Script. In <<received_htlc>> we see an HTLC Bitcoin Script as currently used in the Lightning Network. You can find this definition in https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#offered-htlc-outputs[BOLT3: Transactions].

[[received_htlc]]
.HTLC implemented in Bitcoin Script (BOLT3)
Expand Down Expand Up @@ -401,7 +405,7 @@ OP_SHA256 0575...f6b3 OP_EQUAL

Bob can't spend this HTLC until he knows Dina's secret, so spending the HTLC is conditional on Bob's fulfillment of the payment all the way to Dina.

Once Bob has Dina's secret, Bob can spend this output with an unlocking script containing the secret preimage value +R+
Once Bob has Dina's secret, Bob can spend this output with an unlocking script containing the secret preimage value _R_.

The unlocking script combined with the locking script would produce:

Expand Down

0 comments on commit fe06a41

Please sign in to comment.