BitSleuth
Back to Glossary
Technology

What Are ScriptPubKey and ScriptSig?

ScriptPubKey and ScriptSig are the two halves of Bitcoin's programmable transaction system. ScriptPubKey (locking script) defines the conditions required to spend a UTXO, while ScriptSig (unlocking script) provides the data needed to satisfy those conditions.

Bitcoin Script Language

Bitcoin uses a simple, stack-based scripting language to define spending conditions. This language is intentionally limited to ensure security while enabling flexible transaction types beyond simple payments.

How They Work Together

ScriptPubKey (Locking Script)

Placed in transaction outputs, ScriptPubKey specifies the conditions for spending the bitcoin. Most commonly, it requires a valid digital signature from the owner's private key.

ScriptSig (Unlocking Script)

Placed in transaction inputs, ScriptSig provides the data (like signatures and public keys) that satisfies the ScriptPubKey conditions. When combined and executed, they determine if the transaction is valid.

With SegWit, witness data replaced ScriptSig for signature data, improving transaction malleability and efficiency. Modern tools like Miniscript make it easier to compose complex scripts safely.

Quick Facts

  • ScriptPubKey locks funds to an address
  • ScriptSig unlocks funds
  • SegWit moved witness data out of ScriptSig

Related Terms