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

CC BY-SA 4.0
2022-02-03T00:31:02.263Z
2022-02-03T00:31:02.263Z
Pieter Wuille
<p>I am trying to implement a bitcoin script interpreter and today I stumbled upon a nonstandard transaction in <code>tx_valid.json</code> which gave me a lot of headaches. The transaction in question has the following prevout script public key:</p>
<p><code>DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01</code></p>
<p>and has the CLEANSTACK flag set.</p>
<p>If we disregard the signature present in the script, which is nonstandard, the script is successful (it is the previous test in <code>tx_valid.json</code>)</p>
<p>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.</p>
<p>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.</p>
<p>So where am I wrong?</p>

<script><bitcoin-core-development><transaction-verification>
Trying to understand a nonstandard transaction in bitcoin tests
giacomocaironi
# Trying to understand a nonstandard transaction in bitcoin tests

(Asked by: username_0 on 2022-02-03)

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?

**Tags:** script, bitcoin-core-development, transaction-verification


---

## 1 answers

### Answer by username_1 on 2022-02-03. Score: 1 | Accepted answer

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


---

