THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Multisig and P2WSH: Scripts, Witnesses, and Limits

permalink THAMER
#bip141#bitcoin-multisig#op-checkmultisig#p2wsh#tapscript#witness-script

Bitcoin multisignature spending can require more than one signature to authorize an output. A familiar example is a 2-of-3 script, in which any two of three designated keys can satisfy the spending condition. The implementation details depend on the output type and script version.

What is a classic 2-of-3 multisig script?

A traditional example is:

OP_2 <pubkey-A> <pubkey-B> <pubkey-C> OP_3 OP_CHECKMULTISIG

This uses OP_CHECKMULTISIG under legacy or SegWit v0 rules. Historically, the opcode consumes an extra dummy stack element; BIP147 requires that dummy to be empty for SegWit-related consensus validation. Do not omit it when constructing the witness stack for a classic P2WSH multisig spend.

What does P2WSH commit to?

Pay-to-Witness-Script-Hash (P2WSH) is a SegWit v0 output whose witness program is a 32-byte SHA-256 hash of the witness script. When spent, the witness includes the script and the data needed to satisfy it. A P2WSH address is typically a bc1q Bech32 address on mainnet, but not every bc1q address is P2WSH; P2WPKH also uses SegWit v0.

How does spending work?

For a classic P2WSH multisig output, the spender assembles signatures in the order required by the script, includes the historical empty dummy element, and places the witness script last in the witness stack. The node checks that the witness script hashes to the committed witness program and then executes it under SegWit v0 rules.

How is Taproot different?

Taproot P2TR outputs use SegWit v1 and Bech32m. They may spend via a key-path Schnorr signature or a revealed script path. Tapscript does not use legacy OP_CHECKMULTISIG; developers can use OP_CHECKSIGADD for appropriate signature-counting scripts. A Taproot address is not interchangeable with a P2WSH script hash.

Security and operational concerns

Multisig is not a substitute for key-backup planning. Document signer availability, key rotation or recovery procedures, fee funding, script size, and signing coordination. Test recovery transactions and any timelocks before moving real funds.

Primary references

  • BIP141: Segregated Witness: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki
  • BIP143: Transaction Signature Verification for SegWit v0: https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki
  • BIP147: NULLDUMMY: https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki
  • BIP342: Tapscript: https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects