3

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
morsecoder
  • 14,008
  • 2
  • 42
  • 92

1 Answers1

5

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.)

Nick ODell
  • 29,184
  • 11
  • 69
  • 129