<p>OP_CHECKMULTISIG, OP_CHECKSIG, OP_EQUAL all put true or false on the stack. This means you could use them with an OP_IF or similar, it doesn't have to immediately end execution if its false. OP_VERIFY will, as you quoted, mark the transaction as invalid of the top stack element isn't true, but you may not want to, you may want to perform some additional logic before that.</p>

CC BY-SA 3.0
2017-07-27T11:43:11.723Z
This means that every script that has advanced logics and multiple OP_IF and OP_ENDIF has to end with an OP_VERIFY in case between if and endifs we only have OP_CHECKSIG and OP_CHECKMULTISIG?
skydanc3r
CC BY-SA 3.0
2017-07-27T11:47:03.843Z
This means the following script is invalid: IF
2 <Alice key> <Bob key> 2 CHECKMULTISIGVERIFY
ELSE
<Bob key> CHECKSIGVERIFY SHA256 <hash_of_secret> EQUALVERIFY
ENDIF
skydanc3r
CC BY-SA 3.0
2017-07-27T12:37:06.067Z
You used VERIFY in that script, did you mean to? You don't *need* to end with OP_VERIFY, the script will still be valid at the end if a non-zero (true) value is on the stack. The VERIFY versions are mostly used to mark it as invalid early on rather than evaluating the whole script, like you might use "return false;" in Java or C++
meshcollider
CC BY-SA 3.0
2017-07-27T13:05:09.803Z
Thanks. In my example the second condition after else (providing the secret) will not even be checked in case first condition is not met, because checkmultisigverify will end the script immediately. Got it right?
skydanc3r
CC BY-SA 3.0
2017-07-27T19:21:46.260Z
Yep, correct :)
meshcollider
CC BY-SA 3.0
2017-07-27T19:35:21.143Z
Thanks a lot. It was confusing because in bip65 on github there is this example:    IF
        <service pubkey> CHECKSIGVERIFY
    ELSE
        <expiry time> CHECKLOCKTIMEVERIFY DROP
    ENDIF
    <user pubkey> CHECKSIG but maybe there is mistake here in documentation.
skydanc3r
CC BY-SA 3.0
2017-07-26T21:51:58.093Z
2017-07-26T21:51:58.093Z
meshcollider
<p>I would like to learn the difference, explained as simple as possible, between OP_CHECKMULTISIG / OP_CHECKMULTISIGVERIFY and OP_CHECKSIG / OP_CHECKSIGVERIFY. The only explanation I found is: Same as OP_CHECKMULTISIG (or same as OP_CHECKSIG) except OP_VERIFY is executed afterward.</p>

<p>For OP_VERIFY: Mark a transaction as invalid if top stack value is not true.</p>

<p>Can this be better explained? How does OP_CHECKMULTISIGVERIFY and OP_CHECKMULTISIG differ in practice and in logic of creating scripts? What are the effects (pros and cons) of OP_VERIFY being executed afterward or before? Examples would be highly appreciated.</p>

<script><multi-signature><p2sh>
what is the difference between OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY
skydanc3r
# what is the difference between OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY

(Asked by: username_0 on 2017-07-26)

I would like to learn the difference, explained as simple as possible, between OP\_CHECKMULTISIG / OP\_CHECKMULTISIGVERIFY and OP\_CHECKSIG / OP\_CHECKSIGVERIFY. The only explanation I found is: Same as OP\_CHECKMULTISIG (or same as OP\_CHECKSIG) except OP\_VERIFY is executed afterward.

For OP\_VERIFY: Mark a transaction as invalid if top stack value is not true.

Can this be better explained? How does OP\_CHECKMULTISIGVERIFY and OP\_CHECKMULTISIG differ in practice and in logic of creating scripts? What are the effects (pros and cons) of OP\_VERIFY being executed afterward or before? Examples would be highly appreciated.

**Tags:** script, multi-signature, p2sh


---

## 1 answers

### Answer by username_1 on 2017-07-26. Score: 3 | Accepted answer

OP\_CHECKMULTISIG, OP\_CHECKSIG, OP\_EQUAL all put true or false on the stack. This means you could use them with an OP\_IF or similar, it doesn't have to immediately end execution if its false. OP\_VERIFY will, as you quoted, mark the transaction as invalid of the top stack element isn't true, but you may not want to, you may want to perform some additional logic before that.

> **Comments:**
> **username_0**: This means that every script that has advanced logics and multiple OP_IF and OP_ENDIF has to end with an OP_VERIFY in case between if and endifs we only have OP_CHECKSIG and OP_CHECKMULTISIG?  
> **username_0**: This means the following script is invalid: IF 2 <Alice key> <Bob key> 2 CHECKMULTISIGVERIFY ELSE <Bob key> CHECKSIGVERIFY SHA256 <hash_of_secret> EQUALVERIFY ENDIF  
> **username_1**: You used VERIFY in that script, did you mean to? You don't *need* to end with OP_VERIFY, the script will still be valid at the end if a non-zero (true) value is on the stack. The VERIFY versions are mostly used to mark it as invalid early on rather than evaluating the whole script, like you might use "return false;" in Java or C++  
> **username_0**: Thanks. In my example the second condition after else (providing the secret) will not even be checked in case first condition is not met, because checkmultisigverify will end the script immediately. Got it right?  
> **username_1**: Yep, correct :)  
> **username_0**: Thanks a lot. It was confusing because in bip65 on github there is this example:    IF         <service pubkey> CHECKSIGVERIFY     ELSE         <expiry time> CHECKLOCKTIMEVERIFY DROP     ENDIF     <user pubkey> CHECKSIG but maybe there is mistake here in documentation.  

---

