TeachMeBitcoin

Pattern: 2-of-3 multisig PLUS a timelock condition

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

19. OP_CHECKMULTISIGVERIFY — Multisig with Termination

Overview

OP_CHECKMULTISIGVERIFY is the verifying variant of OP_CHECKMULTISIG. It performs the same M-of-N signature verification but immediately terminates script execution on failure rather than pushing a result to the stack.

Opcode value: 0xaf (decimal 175)
Equivalent to: OP_CHECKMULTISIG OP_VERIFY
Stack behavior: Consumes all multisig inputs, halts on failure, leaves nothing on success

Comparison with OP_CHECKMULTISIG

OP_CHECKMULTISIG:
  Input:  [dummy] [sigs...] [M] [pubkeys...] [N]
  Output: [0x01] or [0x00]
  → Result left on stack for further processing

OP_CHECKMULTISIGVERIFY:
  Input:  [dummy] [sigs...] [M] [pubkeys...] [N]
  Output: (nothing)
  → Script aborts if invalid; continues silently if valid

When to Use CHECKMULTISIGVERIFY

Use OP_CHECKMULTISIGVERIFY when multisig authorization is a prerequisite, and other script logic follows:

# Pattern: 2-of-3 multisig PLUS a timelock condition
scriptPubKey:
  OP_0 <sig1> <sig2>                  ← in scriptSig
  OP_2 <pk1> <pk2> <pk3> OP_3
  OP_CHECKMULTISIGVERIFY              ← verify multisig; fail immediately if invalid
  <locktime>
  OP_CHECKLOCKTIMEVERIFY              ← then check timelock
  OP_DROP
  OP_1                                ← success

If OP_CHECKMULTISIG were used instead:

...
  OP_CHECKMULTISIG   ← pushes 0x01 or 0x00
  OP_VERIFY          ← manually verify the result
  <locktime>
  OP_CHECKLOCKTIMEVERIFY
  ...

Both are functionally identical, but OP_CHECKMULTISIGVERIFY is more concise.

Off-By-One Bug Applies Here Too

The dummy OP_0 element is still required for OP_CHECKMULTISIGVERIFY, as it uses the same underlying code path:

# Still need the dummy element:
scriptSig: OP_0 <sig1> <sig2>
scriptPubKey: OP_2 <pk1> <pk2> <pk3> OP_3 OP_CHECKMULTISIGVERIFY <more_conditions>

Tapscript Alternative

In Tapscript, OP_CHECKMULTISIGVERIFY is disabled. The replacement pattern using OP_CHECKSIGADD naturally supports the "verify and continue" pattern:

# Tapscript 2-of-3 with immediate failure on invalid:
<pk1> OP_CHECKSIG              # push 1 if valid, 0 if not
<pk2> OP_CHECKSIGADD           # add 1 if valid
<pk3> OP_CHECKSIGADD           # add 1 if valid
OP_2 OP_GREATERTHANOREQUAL     # check if count >= 2
☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!