<p><strong>P2SH-P2WSH:</strong></p>

<ul>
<li>Witness script: <code>OP_3 &lt;public key1&gt; &lt;public key2&gt; &lt;public key3&gt; OP_2 OP_CHECKMULTSIG</code></li>
<li>Witness program: <code>SHA256(witness script)</code></li>
<li>redeemScript: <code>OP_0 &lt;witness program&gt;</code></li>
<li>Script hash: <code>Hash160(redeemScript)</code></li>
<li>scriptPubKey: <code>OP_HASH160 &lt;script hash&gt; OP_EQUAL</code></li>
</ul>

<p><strong>P2SH-P2WPKH</strong> (I believe that's what you meant instead of "P2WSH-P2PKH"):</p>

<ul>
<li>Witness program: <code>Hash160(public key)</code></li>
<li>redeemScript: <code>OP_0 &lt;witness program&gt;</code></li>
<li>Script hash: <code>Hash160(redeemScript)</code></li>
<li>scriptPubKey: <code>OP_HASH160 &lt;script hash&gt; OP_EQUAL</code></li>
</ul>

<p><strong>P2WSH-P2PKH</strong> (native P2WSH, but with a P2PKH script inside):</p>

<ul>
<li>Witness script: <code>OP_DUP OP_HASH160 &lt;Hash160(pubkey)&gt; OP_EQUALVERIFY OP_CHECKSIG</code></li>
<li>Witness program: <code>SHA256(witness script)</code></li>
<li>scriptPubKey: <code>OP_0 &lt;witness program&gt;</code></li>
</ul>

<p>Note that you should use P2WPKH instead of this.</p>

<p><strong>Native P2WPKH</strong></p>

<ul>
<li>Witness program: <code>Hash160(public key)</code></li>
<li>scriptPubKey: <code>OP_0 &lt;witness program&gt;</code></li>
</ul>

<p><strong>Native P2WSH</strong></p>

<ul>
<li>Witness script: <code>OP_3 &lt;public key1&gt; &lt;public key2&gt; &lt;public key3&gt; OP_2 OP_CHECKMULTISIG</code></li>
<li>Witness program: <code>SHA256(witness script)</code></li>
<li>scriptPubKey: <code>OP_0 &lt;witness program&gt;</code></li>
</ul>

CC BY-SA 4.0
2020-04-17T15:09:22.723Z
Thanks again for your time, it's an amazing answer for me. I don't understand this script `P2WSH-P2PKH` the third one. I create a bash script to create P2WSH-P2PKH native (bc) where the Witness script is `OP_DUP OP_HASH160 <Hash160(pubkey)> OP_EQUALVERIFY OP_CHECKSIG`. But I have the last scenario (`Native P2WSH`), than I don't have redeem script and script hash.thanks for your advice (Note that you should use P2WPKH instead of this.) but my purpose now is to study, I don't use it :).
monkeyUser
CC BY-SA 4.0
2020-04-17T15:47:05.110Z
I have another question (sorry). You said "P2SH-P2WSH" `redeemScript: OP_0 <witness program>`. When I use `signrawtransactionwithkey` I need to put `redeemScript` in `witnessScript` value. Then why use the name `redeemScript` when I need to use in `witnessScript` value during `signrawtransactionwithkey`?
monkeyUser
CC BY-SA 4.0
2020-04-17T15:53:41.280Z
Update last question. If I change WitnessScript with redeemScript in `signrawtransactionwithkey` works as well. ( I mean the Object key )
monkeyUser
CC BY-SA 4.0
2020-04-17T18:48:13.093Z
@monkeyUser signrawtransaction* secretly doesn't really care about what you name things; it just needs to know all the scripts involved in order to sign.
Pieter Wuille
CC BY-SA 4.0
2020-04-17T18:49:27.593Z
I don't understand your first question (about P2WSH-P2PKH).
Pieter Wuille
CC BY-SA 4.0
2020-04-17T19:18:05.817Z
When I create P2WSH-P2SH (Native and with P2PKH script) I have the same items of Native P2WSH (multisig).
monkeyUser
CC BY-SA 4.0
2020-04-17T19:21:29.210Z
What do you mean by "items"? There would not be any redeemScript in the native witness cases, only in P2SH-wrapped cases.
Pieter Wuille
CC BY-SA 4.0
2020-04-17T19:23:25.790Z
you said "P2WSH-P2PKH (native P2WSH, but with a P2PKH script inside)". It's native, for that reason I don't understand Why I should have `redeemScript` `Script hash`. Thanks
monkeyUser
CC BY-SA 4.0
2020-04-17T19:25:36.333Z
Oh, my mistake! Fixed.
Pieter Wuille
CC BY-SA 4.0
2020-04-17T19:29:10.107Z
thanks for your time, really.
monkeyUser
CC BY-SA 4.0
2020-04-16T18:06:25.073Z
2020-04-17T19:26:13.140Z
2020-04-17T19:26:13.140Z
Pieter Wuille
<p>I have some doubts about naming in witness script/transaction.</p>

<p><strong>P2SH-P2WSH (multisig)</strong></p>

<p><code>WITNESS_SCRIPT = OP_3 &lt;public key1&gt; &lt;public key2&gt; &lt;public key3&gt; &lt;OP_2&gt;</code></p>

<p>(is it witness script or redeem script? For now I will call Witness script)</p>

<p><code>SCRIPTHASH= SHA256 (WITNESS_SCRIPT)</code></p>

<p>is it Witness script Hash or redeem script Hash?</p>

<p><code>REDEEM_SCRIPT=0020+SCRIPTHASH</code></p>

<p>is it redeem script? Maybe it's the redeem script because it is in Scriptsig. (Witness version + Witness program)</p>

<p>In scriptPubKey 
hash160 of <code>(0020+SCRIPTHASH)</code>.</p>

<p>What is its name? Hash160 of ?</p>

<p>And We have <code>OP_HASH160 &lt;Redeem script hash?&gt; OP_EQUAL</code></p>

<p><strong>P2SH-P2WPKH</strong></p>

<p><code>KEYHASH = hash160(&lt;public key&gt;)</code></p>

<p><code>REDEEM_SCRIPT=0014+KEYHASH</code></p>

<p>is it redeem script or witness script? For now I Will call redeem script.</p>

<p>In scriptPubKey
hash160 of <code>(0020+SCRIPTHASH)</code>.</p>

<p>What is its name? Hash160 of ?</p>

<p>And We have <code>OP_HASH160 &lt;Redeem script hash?&gt; OP_EQUAL</code></p>

<p><strong>P2WPKH NATIVE</strong></p>

<p>WITNESS SCRIPT = <code>hash160(&lt;public key&gt;)</code></p>

<p>In scriptpubkey
<code>0014+WITNESS_SCRIPT</code></p>

<p><code>OP_0 &lt;20 bytes witness script hash&gt;</code></p>

<p><strong>P2WSH NATIVE</strong></p>

<p>WITNESS SCRIPT = <code>&lt;OP_2&gt; &lt;pubkey1&gt;&lt;pubkey2&gt;&lt;pubkey3&gt;&lt;OP_3&gt; &lt;OP_CHECKMULTISIG&gt;</code></p>

<p>WITNESS_SCRIPT_HASH = <code>HASH160 (WITNESS SCRIPT)</code></p>

<p>In scriptpubkey</p>

<p><code>0020+WITNESS_SCRIPT_HASH</code></p>

<p><code>OP_0 &lt;32 bytes witness script hash&gt;</code></p>

<p>P2WPKH NATIVE and P2WSH NATIVE should be ok</p>

<transactions><address><segregated-witness>
Naming in segwit script
monkeyUser
# Naming in segwit script

(Asked by: username_0 on 2020-04-16)

I have some doubts about naming in witness script/transaction.

**P2SH-P2WSH (multisig)**

`WITNESS_SCRIPT = OP_3`

(is it witness script or redeem script? For now I will call Witness script)

`SCRIPTHASH= SHA256 (WITNESS_SCRIPT)`

is it Witness script Hash or redeem script Hash?

`REDEEM_SCRIPT=0020+SCRIPTHASH`

is it redeem script? Maybe it's the redeem script because it is in Scriptsig. (Witness version + Witness program)

In scriptPubKey
hash160 of `(0020+SCRIPTHASH)`.

What is its name? Hash160 of ?

And We have `OP_HASH160  OP_EQUAL`

**P2SH-P2WPKH**

`KEYHASH = hash160()`

`REDEEM_SCRIPT=0014+KEYHASH`

is it redeem script or witness script? For now I Will call redeem script.

In scriptPubKey
hash160 of `(0020+SCRIPTHASH)`.

What is its name? Hash160 of ?

And We have `OP_HASH160  OP_EQUAL`

**P2WPKH NATIVE**

WITNESS SCRIPT = `hash160()`

In scriptpubkey
`0014+WITNESS_SCRIPT`

`OP_0 <20 bytes witness script hash>`

**P2WSH NATIVE**

WITNESS SCRIPT =

WITNESS\_SCRIPT\_HASH = `HASH160 (WITNESS SCRIPT)`

In scriptpubkey

`0020+WITNESS_SCRIPT_HASH`

`OP_0 <32 bytes witness script hash>`

P2WPKH NATIVE and P2WSH NATIVE should be ok

**Tags:** transactions, address, segregated-witness


---

## 1 answers

### Answer by username_1 on 2020-04-16. Score: 3 | Accepted answer

**P2SH-P2WSH:**

* Witness script: `OP_3    OP_2 OP_CHECKMULTSIG`
* Witness program: `SHA256(witness script)`
* redeemScript: `OP_0`
* Script hash: `Hash160(redeemScript)`
* scriptPubKey: `OP_HASH160`

> **Comments:**
> **username_0**: Thanks again for your time, it's an amazing answer for me. I don't understand this script `P2WSH-P2PKH` the third one. I create a bash script to create P2WSH-P2PKH native (bc) where the Witness script is `OP_DUP OP_HASH160 <Hash160(pubkey)> OP_EQUALVERIFY OP_CHECKSIG`. But I have the last scenario (`Native P2WSH`), than I don't have redeem script and script hash.thanks for your advice (Note that you should use P2WPKH instead of this.) but my purpose now is to study, I don't use it :).  
> **username_0**: I have another question (sorry). You said "P2SH-P2WSH" `redeemScript: OP_0 <witness program>`. When I use `signrawtransactionwithkey` I need to put `redeemScript` in `witnessScript` value. Then why use the name `redeemScript` when I need to use in `witnessScript` value during `signrawtransactionwithkey`?  
> **username_0**: Update last question. If I change WitnessScript with redeemScript in `signrawtransactionwithkey` works as well. ( I mean the Object key )  
> **username_1**: @username_0 signrawtransaction* secretly doesn't really care about what you name things; it just needs to know all the scripts involved in order to sign.  
> **username_1**: I don't understand your first question (about P2WSH-P2PKH).  
> **username_0**: When I create P2WSH-P2SH (Native and with P2PKH script) I have the same items of Native P2WSH (multisig).  
> **username_1**: What do you mean by "items"? There would not be any redeemScript in the native witness cases, only in P2SH-wrapped cases.  
> **username_0**: you said "P2WSH-P2PKH (native P2WSH, but with a P2PKH script inside)". It's native, for that reason I don't understand Why I should have `redeemScript` `Script hash`. Thanks  
> **username_1**: Oh, my mistake! Fixed.  
> **username_0**: thanks for your time, really.  

---

