When I first started learning how transaction are validated, it made sense why a script language was needed: the scriptPubKey was executed along the scriptSig, the software just executes this "blindly", following the rules of what each Op_code does.

This is the way the first transaction types (P2PK and P2PKH) are actually validated, and this is how I thought all transactions were validated: you have a script language with which you can create all sorts of exotic spending conditions, and the software just executes the scriptPubKeypt alongside the scriptSig to see if the transaction is valid. It's simple and it makes sense.

But now enter P2SH transactions. It took me a long time to get that now, the script is not actually blindly validated by the software anymore. We actually tell the software what it is supposed to do when it encounters such a transactions: it has to verify the locking script provided corresponds with the hash in the scriptPubKey, and then verify the scriptSig with the locking script.

The same is true with Segwit transactions. Here the scriptPubKey is nothing more than a push data of a hashed public key. We have to explicitly tell the software what to do, how to handle such transactions. There's not even a checksig anymore in the scriptPubKey, or any Op_code at all for that matter, in the scriptPubKey or in the witness.

This all seems less "natural" and organic than the previous way of verifying transactions, that is the software blindly running the scriptPubKey and the scriptSig.

And after all this I wonder what is even the point of having a script language at all, if we actually have to explictly tell the software how to handle each transaction type?

To be clear, I'm not for or against anything in particular, I'm just interested in the topic and trying to learn.

1 Answer 1


The first output types you list are bare scripts, in which the output script and input script are actually provided in verbatim and executed literally.

The other output types you mention are examples of standard output types that follow essentially a type of shorthand for a longer script. A specific output script pattern has been defined to be treated according to some fixed rules. The specific rules for these output types are part of the Bitcoin consensus rules.

However, there are other types of outputs that you have not mentioned here that permit the recipient to define arbitrary scripts for their validation, e.g. P2SH, P2SH-P2WSH, P2WSH, and P2TR. When these output types are used in that manner the executed script to determine validity of an input (i.e. Redeem Script, Witness Script, or Leaf Script) may contain arbitrary Script instructions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.