user18196: When executing bitcoin validation scripts, does the final stack have to end with just true on the stack, or can there be some elements under the true? In other words, are both of these final stack configurations valid, or just the first?
Stack1:
true

Stack2:
0 {pub_key} true


user2306: Quoting Bitcoin wiki:

A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero). 

From the source code:
if (CastToBool(stack.back()) == false)
    return false;

(In case you don't know what vector.back() does, it returns the last item.)

18196: <p>When executing bitcoin validation scripts, does the final stack have to end with just <code>true</code> on the stack, or can there be some elements under the <code>true</code>? In other words, are both of these final stack configurations valid, or just the first?</p>

<p>Stack1:</p>

<pre><code>true
</code></pre>

<p>Stack2:</p>

<pre><code>0 {pub_key} true
</code></pre>
 2306: <p><a href="https://en.bitcoin.it/wiki/Script">Quoting Bitcoin wiki:</a></p>

<blockquote>
  <p>A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero). </p>
</blockquote>

<p><a href="https://github.com/bitcoin/bitcoin/blob/25cc1cf8dc03b9ba0ae886d354855adc207b5b6e/src/script/interpreter.cpp#L993">From the source code:</a></p>

<pre><code>if (CastToBool(stack.back()) == false)
    return false;
</code></pre>

<p>(In case you don't know what vector.back() does, <a href="http://www.cplusplus.com/reference/vector/vector/back/">it returns the last item</a>.)</p>
