3

When redeeming a UTXO it is necessary to provide certain values such as a public key and a signature. These values come in the form of a script.

First, the value providing scriptSig script runs. Whatever is left on the stack is fed into the script from the UTXO (scriptPubKey). So what actually runs is pieced together from the UTXO and the redeeming script.

Why is scriptSig a script and not simply a list of serialized values? Is there a use case for providing a script that is more than just a series of OP_PUSHDATA?

3

Don't think of them as separate scripts, but rather as 2 parts of the same script. The software executes both scripts using the same stack, so it's like they were concatenated and run as one. The advantage is that it's the same code that executes each script.

However, you are correct in suspecting there is no reason to have anything other than serialized values for scriptSig, at least with most scripts. With a stack based language such as Bitcoin's script, there are no variables or memory allocation. The only way the results from an earlier part of the script can affect the rest of the script is to push values to the stack to be used as inputs of other operations. This means it is pointless to perform any operation in scriptSig other than pushing values to the stack. As such, transaction inputs that use operations in their scripts are considered non-standard.

The exception to this rule is the multisig script type, which needs to push an extra value onto the stack due to an unfortunate off-by-one error in OP_CHECKMULTISIG. Even so, the OP_0 or OP_FALSE that is used in a multisig scriptSig only pushes values to the stack. That is all a scriptSig should ever do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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