mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-12-23 15:18:11 +00:00
fixes
indent, one additional question,
This commit is contained in:
parent
a1c3e637ae
commit
519e652c4f
@ -434,9 +434,9 @@ code to run in either case
|
||||
|
||||
When reading Bitcoin Script, remember that the condition being evaluated comes *before* the +IF+ opcode.
|
||||
|
||||
==== Flow Control with VERIFY opcodes
|
||||
==== Conditional clauses with VERIFY opcodes
|
||||
|
||||
Another form of flow control in Bitcoin Script is any opcode that ends in +VERIFY+. The +VERIFY+ suffix means that if the condition evaluated is not TRUE, execution of the script terminates immediately and the transaction is deemed invalid.
|
||||
Another form of conditional in Bitcoin Script is any opcode that ends in +VERIFY+. The +VERIFY+ suffix means that if the condition evaluated is not TRUE, execution of the script terminates immediately and the transaction is deemed invalid.
|
||||
|
||||
Unlike an +IF+ clause which offers alternative execution paths, the +VERIFY+ suffix acts as a _guard clause_, continuing only if a precondition is met.
|
||||
|
||||
@ -475,7 +475,7 @@ Bob's unlocking script is identical:
|
||||
|
||||
The script with +IF+ does the same thing as using an opcode with a +VERIFY+ suffix, they both operate as guard clauses. However, the +VERIFY+ construction is more efficient, using one fewer opcode.
|
||||
|
||||
So, when do we use +VERIFY+ and when do we use +IF+? If all we are trying to do is to attach a pre-condition (guard clause), then +VERIFY+ is better. If however, we want to have more than one execution path, then we need an +IF...ELSE+ flow control clause.
|
||||
So, when do we use +VERIFY+ and when do we use +IF+? If all we are trying to do is to attach a pre-condition (guard clause), then +VERIFY+ is better. If however, we want to have more than one execution path (flow control), then we need an +IF...ELSE+ flow control clause.
|
||||
|
||||
==== Using Flow Control in Scripts
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user