Skip to content
DonateБГ

Bitcoin Script

P2MS

P2MS locks an output to several public keys, and m of them must sign to spend it. Learn the m-of-n script, the dummy item and real examples.

By Dimitar Zurnov · Updated 4 Nov 2026
Adapted from Learn Me a Bitcoin by Greg Walker.

P2MS, short for pay to multisig, locks an output to a list of public keys. The lock sets two numbers: m, how many signatures are needed, and n, how many keys there are. A 2-of-3 lock needs valid signatures from two of its three keys. P2MS is a legacy type. Raw multisig is rare on chain today, because most multisig wraps the script in P2SH or P2WSH.

BIP 11 defined M-of-N multisig as a standard transaction type. The earliest examples below are from January 2012.

What does a P2MS locking script look like?

A 2-of-3 bare multisig lock: OP_2, three public keys, OP_3, then OP_CHECKMULTISIG. A 2-of-3 bare multisig lock OP_2: two signatures are needed 52 public key 1, uncompressed 04d81fd5…46b342a2 public key 2, uncompressed 04ec3aff…b0475bb1 public key 3, uncompressed 04b49b49…16d5a5e7 OP_3: three public keys 53 OP_CHECKMULTISIG: check the signatures ae 201 bytes: 1 + 3 × 66 + 1 + 1.
The keys are shortened in the picture. The full script is in the hex below.

The lock is OP_2, the public keys, OP_3, and then OP_CHECKMULTISIG. The whole script is 201 bytes:

524104d81fd577272bbe73308c93009eec5dc9fc319fc1ee2e7066e17220a5d47a18314578be2faea34b9f1f8ca078f8621acd4bc22897b03daa422b9bf56646b342a24104ec3afff0b2b66e8152e9018fe3be3fc92b30bf886b3487a525997d00fd9da2d012dce5d5275854adc3106572a5d1e12d4211b228429f5a7b2f7ba92eb0475bb14104b49b496684b02855bc32f5daefa2e2e406db4418f3b86bca5195600951c7d918cdbe5e6d3736ec2abf2dd7610995c3086976b2c0c7b4e459d10b34a316d5a5e753ae

Each key here is uncompressed, so each one is pushed with 41 and 65 bytes of data. A P2MS lock can mix compressed (33-byte) and uncompressed keys. Output 0 of 581d30e2a73a2db683ac2f15d53590bd0cd72de52555c2722d9d6a78e9fea510 uses this lock.

What does the unlocking script look like?

The scriptSig has an empty first item, then the two signatures:

00483045022100af204ef91b8dba5884df50f87219ccef22014c21dd05aa44470d4ed800b7f6e40220428fe058684db1bb2bfb6061bff67048592c574effc217f0d150daedcf36787601483045022100e8547aa2c2a2761a5a28806d3ae0d1bbf0aeff782f9081dfea67b86cacb321340220771a166929469c34959daf726a2ac0c253f9aff391e58a3c7cb46d8b7e0fdc4801

00 is the empty first item, and each signature is pushed with 48, for 72 bytes. Input 0 of 949591ad468cef5c41656c0a502d9500671ee421fadb590fbc6373000039b693 spends the 2-of-3 lock above.

What is the dummy item?

OP_CHECKMULTISIG has an off-by-one bug: it pops one more item than it should. The spend adds an extra item at the start to absorb it. This is the dummy item. Since BIP 147, the dummy must be empty, which means OP_0 (00). Nodes reject any other value.

The signatures must also appear in the same order as their keys. The next section shows why.

How does a P2MS script run?

Checking a 2-of-3 lock: S1 matches K1, S3 skips K2 and matches K3, so the lock opens. Signatures follow the key order keys in the lock K1 K2 K3 S1 matches S3 skips S3 matches signatures in scriptSig S1 S3 Both found: the lock opens
Signatures must keep the key order. The check moves forward through the keys only.

All the signatures and keys are pushed onto the stack first. Then OP_CHECKMULTISIG works like this:

  1. It pops n, then pops that many public keys off the stack.
  2. It pops m, then pops that many signatures.
  3. It takes the first signature and the first key. If they match, it moves to the next signature. If they do not, it moves to the next key.
  4. A key that has been passed is never checked again.
  5. If every signature found a matching key, it pushes OP_1. Otherwise the script fails.

Because the walk only moves forward, a signature can match a key only if it comes after the previous signature's key. That is why the signatures must follow the key order.

What are the limits on P2MS?

  • A standard bare multisig lock can have at most 3 keys. A larger one is valid if it is mined, but nodes will not relay it.
  • OP_CHECKMULTISIG itself accepts up to 20 keys.
  • Wrapped in P2SH, the redeem script can hold up to 15 compressed keys, because a redeem script can be at most 520 bytes. Uncompressed keys take 66 bytes each, so seven is the most that fit.

Does P2MS have an address?

No. A raw P2MS lock has no address format. You can convert each of its public keys to an address, but the multisig lock itself does not have one. To lock coins to a multisig, wrap the script in P2SH or P2WSH, which do have addresses. Most wallets only let you pay an address, so a raw P2MS lock would need the sender to build the transaction by hand.

P2MS has never been removed from the consensus rules. It became standard in early 2012, before P2SH took effect in April 2012 under BIP 16.

Which P2MS transactions can you check on our explorer?

In this section: Bitcoin Script

All of Bitcoin from zero

Something look wrong? Tell us