diff --git a/ch06.asciidoc b/ch06.asciidoc index 782d00b9..6ee0a87d 100644 --- a/ch06.asciidoc +++ b/ch06.asciidoc @@ -427,18 +427,18 @@ The validation software combines the locking and unlocking scripts and the resul 2 3 OP_ADD 5 OP_EQUAL ---- -As we saw in the step-by-step example in <>, when this script is executed, the result is +OP_TRUE+, making the transaction valid. Not only is this a valid transaction output locking script, but the resulting UTXO could be spent by anyone with the arithmetic skills to know that the number 2 satisfies the script. - -[[simplemath_script]] -.Bitcoin's script validation doing simple math -image::images/mbc2_0604.png["TxScriptSimpleMathExample"] - +As we saw in the step-by-step example in <>, when this script is executed, the result is +OP_TRUE+, making the transaction valid. Not only is this a valid transaction output locking script, but the resulting UTXO could be spent by anyone with the arithmetic skills to know that the number 2 satisfies the script. [TIP] ==== ((("transactions", "valid and invalid")))Transactions are valid if the top result on the stack is +TRUE+ (noted as ++{0x01}++), any other nonzero value, or if the stack is empty after script execution. Transactions are invalid if the top value on the stack is +FALSE+ (a zero-length empty value, noted as ++{}++) or if script execution is halted explicitly by an operator, such as +OP_VERIFY+, +OP_RETURN+, or a conditional terminator such as +OP_ENDIF+. See <> for details. ==== +[[simplemath_script]] +.Bitcoin's script validation doing simple math +image::images/mbc2_0604.png["TxScriptSimpleMathExample"] + + The following is a slightly more complex script, which calculates ++2 + 7 -- 3 + 1++. Notice that when the script contains several operators in a row, the stack allows the results of one operator to be acted upon by the next operator: ---- @@ -486,7 +486,6 @@ When executed, this combined script will evaluate to TRUE if, and only if, the u Figures pass:[#P2PubKHash1] and pass:[#P2PubKHash2] show (in two parts) a step-by-step execution of the combined script, which will prove this is a valid transaction.((("", startref="Tsript06")))((("", startref="Stransact06"))) [[P2PubKHash1]] -[role="smallereighty"] .Evaluating a script for a P2PKH transaction (part 1 of 2) image::images/mbc2_0605.png["Tx_Script_P2PubKeyHash_1"]