Different error messages under "Mandatory script verify flag failed." 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.


script failed on OP_EQUALVERIFY OP
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.
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:


The hash of the public key must match a certain value. (A failure here means you have the wrong key, or no key.)
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