cryptotrading.ink

Bitcoin script

Bitcoin Script

Bitcoin Script is a stack-based, forth-like scripting language used in the Bitcoin network to define the conditions that must be met to spend Bitcoins. It's not a general-purpose programming language like Python or JavaScript; its design deliberately limits its capabilities to ensure the security and determinism of the blockchain. Understanding Bitcoin Script is crucial for grasping the intricacies of cryptocurrency transactions and smart contracts within the Bitcoin ecosystem.

Overview

Bitcoin Script is used within Bitcoin transactions in the locking script (scriptPubKey) and the unlocking script (scriptSig). The locking script defines the conditions for spending the Bitcoins, and the unlocking script provides the data to satisfy those conditions. When a transaction is submitted, the Bitcoin network executes both scripts. If the unlocking script, when run against the locking script's conditions, results in a "true" outcome, the transaction is considered valid.

It’s important to note that Bitcoin Script is *not* Turing complete. This limitation was intentional to prevent infinite loops and complex computations that could potentially compromise the network’s stability. While it can perform basic operations, it lacks features like loops and conditional branching found in fully Turing-complete languages. This impacts the complexity of decentralized applications that can be built directly on Bitcoin, prompting the development of solutions like Lightning Network and sidechains.

Core Concepts