From 940b7f8b5d6932ae7b09d779f398f5c1e2c966f7 Mon Sep 17 00:00:00 2001 From: "myarbrough@oreilly.com" Date: Tue, 18 Nov 2014 07:55:56 -0800 Subject: [PATCH] Made changes to ch05.asciidoc --- ch05.asciidoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ch05.asciidoc b/ch05.asciidoc index 89fda9bf..5e77f943 100644 --- a/ch05.asciidoc +++ b/ch05.asciidoc @@ -291,7 +291,7 @@ Bitcoin's scripting language is called a stack-based language because it uses a The scripting language executes the script by processing each item from left to right. Numbers (data constants) are pushed onto the stack. Operators push or pop one or more parameters from the stack, act on them, and might push a result onto the stack. For example, +OP_ADD+ will pop two items from the stack, add them, and push the resulting sum onto the stack. -Conditional operators evaluate a condition producing a boolean result of TRUE or FALSE. For example, +OP_EQUAL+ pops two items from the stack and pushes TRUE (TRUE is represented by the number 1) if they are equal or FALSE (represented by zero) if they are not equal. Bitcoin transaction scripts usually contain a conditional operator, so that they can produce the TRUE result that signifies a valid transaction. +Conditional operators evaluate a condition, producing a boolean result of TRUE or FALSE. For example, +OP_EQUAL+ pops two items from the stack and pushes TRUE (TRUE is represented by the number 1) if they are equal or FALSE (represented by zero) if they are not equal. Bitcoin transaction scripts usually contain a conditional operator, so that they can produce the TRUE result that signifies a valid transaction. In <>, the script +2 3 OP_ADD 5 OP_EQUAL+ demonstrates the arithmetic addition operator +OP_ADD+, adding two numbers and putting the result on the stack, followed by the conditional operator +OP_EQUAL+, which checks that the resulting sum is equal to +5+. For brevity, the +OP_+ prefix is omitted in the step-by-step example. @@ -309,11 +309,12 @@ Try validating the preceding script yourself using pencil and paper. When the sc Although most locking scripts refer to a bitcoin address or public key, thereby requiring proof of ownership to spend the funds, the script does not have to be that complex. Any combination of locking and unlocking scripts that results in a TRUE value is valid. The simple arithmetic we used as an example of the scripting language is also a valid locking script that can be used to lock a transaction output. Use part of the arithmetic example script as the locking script: + ---- 3 OP_ADD 5 OP_EQUAL ---- -which can be satisfied by transaction containing an input with the unlocking script: +which can be satisfied by a transaction containing an input with the unlocking script: ---- 2 ----