I am trying to implement a bitcoin script interpreter and today I stumbled upon a nonstandard transaction in tx_valid.json which gave me a lot of headaches. The transaction in question has the following prevout script public key:

DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01

and has the CLEANSTACK flag set.

If we disregard the signature present in the script, which is nonstandard, the script is successful (it is the previous test in tx_valid.json)

Now if we add the signature to the script, at the end of execution there will be two values on the stack, 1 and 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01. Because of the CLEANSTACK flag, which requires only one value on the stack, I think that the script should fail.

One idea I had is that FindAndDelete deletes all the other signatures in the script public key, so now we have only 1 on the stack. However I am not sure about this because from what I have read FindAndDelete only deletes values in the subScript when verifying OP_CHECKSIG and OP_CHECKMULTISIG, and does not modify the actual script.

So where am I wrong?

1 Answer 1


The flags listed in the file are inverted: it gives under which flags validation isn't expected to succeed (or in other words: under all flags except the ones listed there, it is expected to succeed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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