<blockquote>
  <p>But aren't both errors just variant of a failure in executing the OP_EQUALVERIFY? At what step of the evaluation each error is thrown and what can we make out of it?</p>
</blockquote>

<p>No, they're different errors. There are two rules that must be satisifed here:</p>

<ol>
<li>The hash of the public key must match a certain value. (A failure here means you have the wrong key, or no key.)</li>
<li>The signature must be valid for the message and public key. (<code>OP_CHECKSIG</code> does not error immediately. It returns 0, which causes the script to fail.)</li>
</ol>

<p>There are other script errors, too. See this list: <a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/script_error.cpp" rel="noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/script/script_error.cpp</a></p>

CC BY-SA 3.0
2016-11-29T00:17:57.193Z
2016-11-29T00:17:57.193Z
Nick ODell
<p>I was facing the same issue while I was creating a raw transaction. I got the message: mandatory-script-verify-flag-failed </p>

<pre><code>(Script failed an OP_EQUALVERIFY operation)
</code></pre>

<p>I figure out that the issue behind is that I am signing with an erroneous key which wasn't related to the UTXO.
I had to backup the key tied to the UTXO address using dumpprivkey and sign with it.</p>

CC BY-SA 3.0
2017-08-12T09:24:47.810Z
2017-08-12T10:48:00.020Z
2017-08-12T10:48:00.020Z
Badr Bellaj
<p>I've been playing with raw transactions and signed transaction and I've noticed that the error "Mandatory script verify flag failed" comes in two variations.</p>

<ol>
<li>script failed on OP_EQUALVERIFY OP</li>
<li>Script evaluated without error but finished with a false/empty top stack element.</li>
</ol>

<p>Now, it appears that error number one is given whenever I try to send a transaction with the wrong TXID or index number. 
The second error can appear when I provide the wrong signature.</p>

<p>But aren't both errors just variant of a failure in executing the OP_EQUALVERIFY? At what step of the evaluation each error is thrown and what can we make out of it?</p>

<p>I'll highly appreciate any pointer you might have. I really struggle here to differentiate the two.</p>

<transactions><script><transaction-verification><verification>
Different error messages under "Mandatory script verify flag failed."
shultz
# Different error messages under "Mandatory script verify flag failed."

(Asked by: username_0 on 2016-11-28)

I've been playing with raw transactions and signed transaction and I've noticed that the error "Mandatory script verify flag failed" comes in two variations.

1. script failed on OP\_EQUALVERIFY OP
2. Script evaluated without error but finished with a false/empty top stack element.

Now, it appears that error number one is given whenever I try to send a transaction with the wrong TXID or index number.
The second error can appear when I provide the wrong signature.

But aren't both errors just variant of a failure in executing the OP\_EQUALVERIFY? At what step of the evaluation each error is thrown and what can we make out of it?

I'll highly appreciate any pointer you might have. I really struggle here to differentiate the two.

**Tags:** transactions, script, transaction-verification, verification


---

## 2 answers

### Answer by username_1 on 2016-11-29. Score: 6

> But aren't both errors just variant of a failure in executing the OP\_EQUALVERIFY? At what step of the evaluation each error is thrown and what can we make out of it?

No, they're different errors. There are two rules that must be satisifed here:

1. The hash of the public key must match a certain value. (A failure here means you have the wrong key, or no key.)
2. The signature must be valid for the message and public key. (`OP_CHECKSIG` does not error immediately. It returns 0, which causes the script to fail.)

There are other script errors, too. See this list: <https://github.com/bitcoin/bitcoin/blob/master/src/script/script_error.cpp>


---

### Answer by username_2 on 2017-08-12. Score: 3

I was facing the same issue while I was creating a raw transaction. I got the message: mandatory-script-verify-flag-failed 
(Script failed an OP_EQUALVERIFY operation)

I figure out that the issue behind is that I am signing with an erroneous key which wasn't related to the UTXO.
I had to backup the key tied to the UTXO address using dumpprivkey and sign with it.


---

