2
0
mirror of https://github.com/lnbook/lnbook synced 2024-11-15 00:15:05 +00:00

Edited 08_routing_htlcs.asciidoc with Atlas code editor

This commit is contained in:
kristen@oreilly.com 2021-10-19 12:12:44 -07:00
parent 6f6490a65a
commit 2e6012ad13

View File

@ -411,9 +411,9 @@ The unlocking script combined with the locking script would produce:
The Bitcoin Script engine would evaluate this script as follows:
1. +R+ is pushed to the stack
2. The OP_SHA256 operator takes the value +R+ off the stack and hashes it, pushing the result +H~R~+ to the stack
3. +H+ is pushed to the stack
1. +R+ is pushed to the stack.
2. The OP_SHA256 operator takes the value +R+ off the stack and hashes it, pushing the result +H~R~+ to the stack.
3. +H+ is pushed to the stack.
4. The OP_EQUAL operator compares +H+ and +H~R~+. If they are equal, the result is +TRUE+, the script is complete, and the payment is verified.
==== Extending HTLCs from Alice to Dina
@ -522,7 +522,7 @@ Let's look at the first part of the HTLC script so far:
OP_SHA256 <H> OP_EQUALVERIFY
----
If we look at this in the preceding symbolic representation, it looks like the +OP_+ operators take up the most space. But that's not the case. Bitcoin Script is encoded in binary, with each operator representing one byte. Meanwhile, the +<H>+ value we use as a placeholder for the payment hash is a 32-byte (256-bit) value. You can find a listing of all the Bitcoin Script operators and their binary and hex encoding in https://en.bitcoin.it/wiki/Script[Bitcoin Wiki: Script], or in https://github.com/bitcoinbook/bitcoinbook/blob/develop/appdx-scriptops.asciidoc[_Mastering Bitcoin_ Appendix: Transaction Script Language Operators, Constants, and Symbols].
If we look at this in the preceding symbolic representation, it looks like the +OP_+ operators take up the most space. But that's not the case. Bitcoin Script is encoded in binary, with each operator representing one byte. Meanwhile, the +<H>+ value we use as a placeholder for the payment hash is a 32-byte (256-bit) value. You can find a listing of all the Bitcoin Script operators and their binary and hex encoding in https://en.bitcoin.it/wiki/Script[Bitcoin Wiki: Script], or in https://github.com/bitcoinbook/bitcoinbook/blob/develop/appdx-scriptops.asciidoc[Appendix D, "Transaction Script Language Operators, Constants, and Symbols", in _Mastering Bitcoin_].
Represented in hexadecimal, our HTLC script would look like this: