Is a script spendable if the top item left on the stack evaluates to "TRUE
", and that is the only item left in the stack?
In other words, is it okay for multiple items to be left on the stack?
For example,
A scriptPubKey
+ scriptSig
is spenable if an OP_1
(or anything other than OP_0
or nothing) is left on top of the stack after the script has finished executing.
scriptPubKey: OP_DUP OP_HASH160 <pubkeyhash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <signature> <pubkey>
If the <pubkey>
hashes to the <pubkeyhash>
, and the <signature>
corresponds the <pubkey>
, then OP_CHECKSIG
will end up leaving the following on the stack:
stack: OP_1
However, if you had the following scriptPubKey
+ scriptSig
:
scriptPubKey: OP_2 OP_3
scriptSig: OP_1
This would leave the following stack:
stack: OP_1 OP_2 OP_3
Would this evaluate to TRUE
and mean the script is spendable?
I'm getting a non-mandatory-script-verify-flag (Extra items left on stack after execution) (code 64)
error, and I'm wondering if this is the problem.