Skip to Content
Foundations of Blockchain
book

Foundations of Blockchain

by Koshik Raj
January 2019
Beginner to intermediate
372 pages
11h 17m
English
Packt Publishing
Content preview from Foundations of Blockchain

Locking and unlocking scripts

Bitcoin uses a similar method of script execution but has a different set of opcodes. Bitcoin transactions use locking and unlocking scripts, which are executed together to verify a transaction. As mentioned earlier, a locking script is a spending condition specified in the transaction output, and an unlocking script satisfies this condition when the two scripts are executed together.

We can create a simple locking and unlocking script by breaking down the previous script example. Part of the script could form a locking script, as shown here:

4 OP_ADD 6 OP_EQUAL 

This could only be satisfied by an unlocking script:

2 

Any node will validate these scripts by combining and executing the locking and unlocking scripts ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain Basics

Blockchain Basics

Daniel Drescher
What Is Blockchain?

What Is Blockchain?

Sir John Hargrave, Evan Karnoupakis
Mastering Blockchain

Mastering Blockchain

Lorne Lantz, Daniel Cawrey

Publisher Resources

ISBN: 9781789139396Supplemental Content