Bitcoin Forum
June 14, 2024, 09:02:47 AM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Differences between so-called "native P2WSH" and "P2SH-P2WSH"?  (Read 98 times)
NotATether (OP)
Legendary
*
Offline Offline

Activity: 1638
Merit: 6896


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 14, 2021, 06:21:37 AM
Merited by ABCbits (1)
 #1

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 <signature1> <1 <pubkey1> <pubkey2> 2 CHECKMULTISIG>
    scriptSig:    (empty)
    scriptPubKey: 0 <32-byte-hash>
                  (0x0020{32-byte-hash})

P2WSH nested in BIP16 P2SH

    witness:      0 <signature1> <1 <pubkey1> <pubkey2> 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)

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
pooya87
Legendary
*
Offline Offline

Activity: 3486
Merit: 10639



View Profile
March 14, 2021, 07:05:45 AM
Merited by ABCbits (3), NotATether (1), aesthete2022 (1)
 #2

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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!