Scripts and Script Language: Script Construction (Lock + Unlock) | Saylor Academy (2024)

Scripts and Script Language

Now we begin our deep dive into Bitcoin scripting! Let's start by reading these sections on scripting.

Script Construction (Lock + Unlock)

Bitcoin's transaction validation engine relies on two types of scripts to validate transactions: a locking script and an unlocking script.

A locking script is a spending condition placed on an output: it specifies the conditions that must be met to spend the output in the future. Historically, the locking script was called a scriptPubKey, because it usually contained a public key or bitcoin address (public key hash). In this book we refer to it as a "locking script" to acknowledge the much broader range of possibilities of this scripting technology. In most bitcoin applications, what we refer to as a locking script will appear in the source code as scriptPubKey. You will also see the locking script referred to as a witness script or more generally as a cryptographic puzzle. These terms all mean the same thing, at different levels of abstraction.

An unlocking script is a script that "solves," or satisfies, the conditions placed on an output by a locking script and allows the output to be spent. Unlocking scripts are part of every transaction input. Most of the time they contain a digital signature produced by the user's wallet from his or her private key. Historically, the unlocking script was called scriptSig, because it usually contained a digital signature. In most bitcoin applications, the source code refers to the unlocking script as scriptSig. You will also see the unlocking script referred to as a witness. In this book, we refer to it as an "unlocking script" to acknowledge the much broader range of locking script requirements, because not all unlocking scripts must contain signatures.

Every bitcoin validating node will validate transactions by executing the locking and unlocking scripts together. Each input contains an unlocking script and refers to a previously existing UTXO. The validation software will copy the unlocking script, retrieve the UTXO referenced by the input, and copy the locking script from that UTXO. The unlocking and locking script are then executed in sequence. The input is valid if the unlocking script satisfies the locking script conditions (see Separate execution of unlocking and locking scripts). All the inputs are validated independently, as part of the overall validation of the transaction.

Note that the UTXO is permanently recorded in the blockchain, and therefore is invariable and is unaffected by failed attempts to spend it by reference in a new transaction. Only a valid transaction that correctly satisfies the conditions of the output results in the output being considered as "spent" and removed from the set of unspent transaction outputs (UTXO set).

Combining scriptSig and scriptPubKey to evaluate a transaction script is an example of the unlocking and locking scripts for the most common type of bitcoin transaction (a payment to a public key hash), showing the combined script resulting from the concatenation of the unlocking and locking scripts prior to script validation.

Scripts and Script Language: Script Construction (Lock + Unlock) | Saylor Academy (3)

Figure 4. Combining scriptSig and scriptPubKey to evaluate a transaction script

The bitcoin transaction script language is stateless, in that there is no state prior to execution of the script, or state saved after execution of the script. Therefore, all the information needed to execute a script is contained within the script. A script will predictably execute the same way on any system. If your system verifies a script, you can be sure that every other system in the bitcoin network will also verify the script, meaning that a valid transaction is valid for everyone and everyone knows this. This predictability of outcomes is an essential benefit of the bitcoin system.

Scripts and Script Language: Script Construction (Lock + Unlock) | Saylor Academy (2024)
Top Articles
Wholesale Real Estate Investing 101: Getting Started
Cash Concentration - Definition and Benefits
Fighter Torso Ornament Kit
Forozdz
Goodbye Horses: The Many Lives of Q Lazzarus
The Daily News Leader from Staunton, Virginia
Triumph Speed Twin 2025 e Speed Twin RS, nelle concessionarie da gennaio 2025 - News - Moto.it
Apply A Mudpack Crossword
Gameday Red Sox
Www Thechristhospital Billpay
Ave Bradley, Global SVP of design and creative director at Kimpton Hotels & Restaurants | Hospitality Interiors
Most McDonald's by Country 2024
Teacup Yorkie For Sale Up To $400 In South Carolina
Beverage Lyons Funeral Home Obituaries
Ups Print Store Near Me
Gina Wilson All Things Algebra Unit 2 Homework 8
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Rust Belt Revival Auctions
Gina Wilson Angle Addition Postulate
Fiona Shaw on Ireland: ‘It is one of the most successful countries in the world. It wasn’t when I left it’
Violent Night Showtimes Near Johnstown Movieplex
Anesthesia Simstat Answers
They Cloned Tyrone Showtimes Near Showbiz Cinemas - Kingwood
Login.castlebranch.com
Ncal Kaiser Online Pay
Jail Roster Independence Ks
Dl.high Stakes Sweeps Download
How often should you visit your Barber?
Wells Fargo Bank Florida Locations
The Ultimate Guide to Obtaining Bark in Conan Exiles: Tips and Tricks for the Best Results
Pnc Bank Routing Number Cincinnati
Strange World Showtimes Near Regal Edwards West Covina
Whas Golf Card
Weekly Math Review Q4 3
Everything You Need to Know About NLE Choppa
Los Garroberros Menu
Pay Entergy Bill
877-292-0545
Joey Gentile Lpsg
Nail Salon Open On Monday Near Me
The Attleboro Sun Chronicle Obituaries
Differential Diagnosis
Mathews Vertix Mod Chart
Strange World Showtimes Near Century Stadium 25 And Xd
UWPD investigating sharing of 'sensitive' photos, video of Wisconsin volleyball team
Jane Powell, MGM musical star of 'Seven Brides for Seven Brothers,' 'Royal Wedding,' dead at 92
Theater X Orange Heights Florida
Rick And Morty Soap2Day
303-615-0055
Tweedehands camper te koop - camper occasion kopen
Basic requirements | UC Admissions
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6278

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.