Author

Topic: Differences between so-called "native P2WSH" and "P2SH-P2WSH"? (Read 121 times)

legendary
Activity: 3472
Merit: 10611
Whenever you want to pay to a script instead of to a pubkey hash you have to use one of the "pay to script hash" scripts. P2SH is the legacy form and P2WSH is the witness form that has lower weight. For backward compatibility you can wrap the P2WSH in a P2SH but essentially both legacy and SegWit "pay to script hashe" scripts are doing the same thing.

For example in a multisig design you have
- a redeem script (containing pubkeys, m and n, OP_CheckMultiSig)
- the signature(s)
In P2SH you put the above two in signature script as a script while in P2WSH you put them in witness as stack items.
In a P2SH-P2WSH you still put the above two in witness as stack items but you also add another script to signature script for backward compatibility.

The other difference is some details of the pubkey script. P2SH uses Hash160 while P2WSH uses SHA256 both computing hash of the redeem script.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
To my understanding, P2SH-P2WSH, or at least that's what the bitcoin developer guide calls it, is a P2WSH script wrapped in a P2SH script. While P2WSH is just P2SH with a witness data field.

Is this script format in BIP141 the only difference between the two?

P2WSH
    witness:      0 <1 2 CHECKMULTISIG>
    scriptSig:    (empty)
    scriptPubKey: 0 <32-byte-hash>
                  (0x0020{32-byte-hash})

P2WSH nested in BIP16 P2SH

    witness:      0 <1 2 CHECKMULTISIG>
    scriptSig:    <0 <32-byte-hash>>
                  (0x220020{32-byte-hash})
    scriptPubKey: HASH160 <20-byte-hash> EQUAL
                  (0xA914{20-byte-hash}87)

Both of these have CHECKMUKTISIG scripts in their opcodes, so is it possible for a Multisig address to use either of these scripts? (I am assuming that a Multisig private key with a "3" address is pinned to one of these script types)
Jump to: