From e9e2b53769f050b3df259a39fa4cf5e80421c536 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 26 Mar 2018 13:39:13 -0700 Subject: [PATCH 1/5] Fix the description of OP_TUCK. The code is https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L686-L693 valtype vch = stacktop(-1); stack.insert(stack.end()-2, vch); which looks to me like it turns bottom-> ..., D, C, B, A <-top into bottom-> ..., D, C, A, B, A <-top --- appdx-scriptops.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appdx-scriptops.asciidoc b/appdx-scriptops.asciidoc index 6cfb13e1..f051c68e 100644 --- a/appdx-scriptops.asciidoc +++ b/appdx-scriptops.asciidoc @@ -81,7 +81,7 @@ Tables and descriptions sourced from https://en.bitcoin.it/wiki/Script[]. | OP_ROLL | 0x7a | Pop value N from top, then move the Nth item to the top of the stack | OP_ROT | 0x7b | Rotate the top three items in the stack | OP_SWAP | 0x7c | Swap the top three items in the stack -| OP_TUCK | 0x7d | Copy the top item and insert it between the top and second item. +| OP_TUCK | 0x7d | Insert a copy of the top item just below the second item |======= <> shows string operators. From f0beb7b613455afcf218fa495f8e4c016c0dfc4c Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 26 Mar 2018 13:52:51 -0700 Subject: [PATCH 2/5] Italicize a few disabled opcodes. --- appdx-scriptops.asciidoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/appdx-scriptops.asciidoc b/appdx-scriptops.asciidoc index f051c68e..ef562327 100644 --- a/appdx-scriptops.asciidoc +++ b/appdx-scriptops.asciidoc @@ -133,11 +133,11 @@ Tables and descriptions sourced from https://en.bitcoin.it/wiki/Script[]. | OP_0NOTEQUAL | 0x92 | If top item is 0 return 0, otherwise return 1 | OP_ADD | 0x93 | Pop top two items, add them and push result | OP_SUB | 0x94 | Pop top two items, subtract first from second, push result -| OP_MUL | 0x95 | Disabled (multiply top two items) -| OP_DIV | 0x96 | Disabled (divide second item by first item) -| OP_MOD | 0x97 | Disabled (remainder divide second item by first item) -| OP_LSHIFT | 0x98 | Disabled (shift second item left by first item number of bits) -| OP_RSHIFT | 0x99 | Disabled (shift second item right by first item number of bits) +| _OP_MUL_ | 0x95 | Disabled (multiply top two items) +| _OP_DIV_ | 0x96 | Disabled (divide second item by first item) +| _OP_MOD_ | 0x97 | Disabled (remainder divide second item by first item) +| _OP_LSHIFT_ | 0x98 | Disabled (shift second item left by first item number of bits) +| _OP_RSHIFT_ | 0x99 | Disabled (shift second item right by first item number of bits) | OP_BOOLAND | 0x9a | Boolean AND of top two items | OP_BOOLOR | 0x9b | Boolean OR of top two items | OP_NUMEQUAL | 0x9c | Return TRUE if top two items are equal numbers From c4f2e530df22f82be12d0791acef37ebc589452e Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 26 Mar 2018 14:17:11 -0700 Subject: [PATCH 3/5] Replace some hyphens. --- appdx-scriptops.asciidoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/appdx-scriptops.asciidoc b/appdx-scriptops.asciidoc index ef562327..49577231 100644 --- a/appdx-scriptops.asciidoc +++ b/appdx-scriptops.asciidoc @@ -15,12 +15,12 @@ Tables and descriptions sourced from https://en.bitcoin.it/wiki/Script[]. |======= | Symbol | Value (hex) | Description | OP_0 or OP_FALSE | 0x00 | An empty array is pushed onto the stack -| 1-75 | 0x01-0x4b | Push the next N bytes onto the stack, where N is 1 to 75 bytes +| 1 to 75 | 0x01 to 0x4b | Push the next N bytes onto the stack, where N is 1 to 75 bytes | OP_PUSHDATA1 | 0x4c | The next script byte contains N, push the following N bytes onto the stack | OP_PUSHDATA2 | 0x4d | The next two script bytes contain N, push the following N bytes onto the stack | OP_PUSHDATA4 | 0x4e | The next four script bytes contain N, push the following N bytes onto the stack | OP_1NEGATE | 0x4f | Push the value "–1" onto the stack -| OP_RESERVED | 0x50 | Halt - Invalid transaction unless found in an unexecuted OP_IF clause +| OP_RESERVED | 0x50 | Halt—Invalid transaction unless found in an unexecuted OP_IF clause | OP_1 or OP_TRUE| 0x51 | Push the value "1" onto the stack | OP_2 to OP_16 | 0x52 to 0x60 | For OP_N, push the value "N" onto the stack, e.g., OP_2 pushes "2" |======= @@ -111,8 +111,8 @@ Tables and descriptions sourced from https://en.bitcoin.it/wiki/Script[]. | _OP_XOR_ | 0x86 | Disabled (Boolean XOR of two top items) | OP_EQUAL | 0x87 | Push TRUE (1) if top two items are exactly equal, push FALSE (0) otherwise | OP_EQUALVERIFY | 0x88 | Same as OP_EQUAL, but run OP_VERIFY after to halt if not TRUE -| OP_RESERVED1 | 0x89 | Halt - Invalid transaction unless found in an unexecuted OP_IF clause -| OP_RESERVED2 | 0x8a | Halt - Invalid transaction unless found in an unexecuted OP_IF clause +| OP_RESERVED1 | 0x89 | Halt—Invalid transaction unless found in an unexecuted OP_IF clause +| OP_RESERVED2 | 0x8a | Halt—Invalid transaction unless found in an unexecuted OP_IF clause |======= [role="pagebreak-before"] @@ -179,7 +179,7 @@ Tables and descriptions sourced from https://en.bitcoin.it/wiki/Script[]. [options="header"] |======= | Symbol | Value (hex) | Description -| OP_NOP1-OP_NOP10 | 0xb0-0xb9 | Does nothing, ignored +| OP_NOP1 to OP_NOP10 | 0xb0 to 0xb9 | Does nothing, ignored |======= From 8fb3e8946e4880d21e2dc0bafc5927cfec423b58 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 26 Mar 2018 14:18:40 -0700 Subject: [PATCH 4/5] Add a missing period. (This sentence appears in Appendix D, in my PDF copy!) --- ch07.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch07.asciidoc b/ch07.asciidoc index f92c7384..7d709f32 100644 --- a/ch07.asciidoc +++ b/ch07.asciidoc @@ -710,7 +710,7 @@ With Segregated Witness, Alice would create a Pay-to-Witness-Public-Key-Hash (P2 0 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 ---- -As you can see, a Segregated Witness output’s locking script is much simpler than a traditional output. It consists of two values that are pushed on to the script evaluation stack. To an old (nonsegwit-aware) bitcoin client, the two pushes would look like an output that anyone can spend and does not require a signature (or rather, can be spent with an empty signature). To a newer, segwit-aware client, the first number (0) is interpreted as a version number (the _witness version_) and the second part (20 bytes) is the equivalent of a locking script known as a _witness program_. The 20-byte witness program is simply the hash of the public key, as in a P2PKH script +As you can see, a Segregated Witness output’s locking script is much simpler than a traditional output. It consists of two values that are pushed on to the script evaluation stack. To an old (nonsegwit-aware) bitcoin client, the two pushes would look like an output that anyone can spend and does not require a signature (or rather, can be spent with an empty signature). To a newer, segwit-aware client, the first number (0) is interpreted as a version number (the _witness version_) and the second part (20 bytes) is the equivalent of a locking script known as a _witness program_. The 20-byte witness program is simply the hash of the public key, as in a P2PKH script. Now, let’s look at the corresponding transaction that Bob uses to spend this output. For the original script (nonsegwit), Bob’s transaction would have to include a signature within the transaction input: From 40206be1468a91dcde953138d6a38e023fced325 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 26 Mar 2018 14:27:06 -0700 Subject: [PATCH 5/5] s/indexi/index/ --- appdx-bitcore.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appdx-bitcore.asciidoc b/appdx-bitcore.asciidoc index d2f22015..2318c3a0 100644 --- a/appdx-bitcore.asciidoc +++ b/appdx-bitcore.asciidoc @@ -58,7 +58,7 @@ Creating and signing a transaction from an UTXO: ---- > utxo = { txId: transaction id containing an unspent output, - outputIndex: output indexi e.g. 0, + outputIndex: output index e.g. 0, address: addressOfUtxo, script: bitcore.Script.buildPublicKeyHashOut(addressOfUtxo).toString(), satoshis: amount sent to the address