<p>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 <a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L232" rel="nofollow">same code</a> that <a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L1369" rel="nofollow">executes each script</a>.</p>

<p>However, you are correct in suspecting there is no reason to have anything other than serialized values for <code>scriptSig</code>, 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 <code>scriptSig</code> other than pushing values to the stack.  As such, transaction inputs that use operations in their scripts are considered <a href="https://bitcoin.org/en/developer-guide#standard-transactions" rel="nofollow">non-standard</a>.</p>

<p>The exception to this rule is the <a href="https://bitcoin.org/en/developer-guide#multisig" rel="nofollow">multisig</a> script type, which needs to push an extra value onto the stack due to an unfortunate off-by-one error in <a href="https://bitcoin.org/en/developer-reference#term-op-checkmultisig" rel="nofollow"><code>OP_CHECKMULTISIG</code></a>.  Even so, the <code>OP_0</code> or <code>OP_FALSE</code> that is used in a multisig <code>scriptSig</code> only pushes values to the stack.  That is all a <code>scriptSig</code> should ever do.</p>

CC BY-SA 3.0
2016-08-12T20:48:40.663Z
2016-08-12T20:48:40.663Z
Jestin
<p>When redeeming a UTXO it is necessary to provide certain values such as a public key and a signature. <a href="https://en.bitcoin.it/wiki/Transaction#Input" rel="nofollow">These values come in the form of a script.</a></p>

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

<p>Why is <code>scriptSig</code> 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 <code>OP_PUSHDATA</code>?</p>

<transactions><script>
Why are redeeming inputs themselves scripts?
boot4life
# Why are redeeming inputs themselves scripts?

(Asked by: username_0 on 2016-08-12)

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.](https://en.bitcoin.it/wiki/Transaction#Input)

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`?

**Tags:** transactions, script


---

## 1 answers

### Answer by username_1 on 2016-08-12. Score: 3 | Accepted answer

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](https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L232) that [executes each script](https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L1369).

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](https://bitcoin.org/en/developer-guide#standard-transactions).

The exception to this rule is the [multisig](https://bitcoin.org/en/developer-guide#multisig) script type, which needs to push an extra value onto the stack due to an unfortunate off-by-one error in [`OP_CHECKMULTISIG`](https://bitcoin.org/en/developer-reference#term-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.


---

