TeachMeBitcoin

The P2SH-P2WSH Redeem Script

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

The P2SH-P2WSH Redeem Script

To "Nest" a multisig SegWit script, we use a specific 34-byte Redeem Script. This script acts as a pointer, telling the Bitcoin Virtual Machine to look for a 32-byte hash in the Witness data.

1. The 34-Byte Template

The Redeem Script for a P2SH-P2WSH output follows this pattern: 00 20 [32-Byte SHA256 Script Hash]

2. Why 32 bytes instead of 20?

Legacy P2SH and single-key SegWit use 20-byte HASH160. However, for multisig and complex scripts, SegWit upgraded to 32-byte SHA256.

3. The Unlocking Script (ScriptSig)

When spending these coins, your ScriptSig must contain the 34-byte Redeem Script: 22 0020[32-byte-hash]

4. Nested vs. Native

Type ID Length Hash Algorithm Signal Opcode
P2WPKH (Single) 20 Bytes HASH160 0x14
P2WSH (Multisig) 32 Bytes SHA256 0x20

In the next section, we will clarify the difference between the Witness Script and the Redeem Script.

☕ 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!