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

P2SH-P2WSH (multisig)

WITNESS_SCRIPT = OP_3 &lt;public key1&gt; &lt;public key2&gt; &lt;public key3&gt; &lt;OP_2&gt;

(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 &lt;Redeem script hash?&gt; OP_EQUAL

P2SH-P2WPKH

KEYHASH = hash160(&lt;public key&gt;)

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 &lt;Redeem script hash?&gt; OP_EQUAL

P2WPKH NATIVE

WITNESS SCRIPT = hash160(&lt;public key&gt;)

In scriptpubkey
0014+WITNESS_SCRIPT

OP_0 &lt;20 bytes witness script hash&gt;

P2WSH NATIVE

WITNESS SCRIPT = &lt;OP_2&gt; &lt;pubkey1&gt;&lt;pubkey2&gt;&lt;pubkey3&gt;&lt;OP_3&gt; &lt;OP_CHECKMULTISIG&gt;

WITNESS_SCRIPT_HASH = HASH160 (WITNESS SCRIPT)

In scriptpubkey

0020+WITNESS_SCRIPT_HASH

OP_0 &lt;32 bytes witness script hash&gt;

P2WPKH NATIVE and P2WSH NATIVE should be ok
P2SH-P2WSH:


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


P2SH-P2WPKH (I believe that's what you meant instead of "P2WSH-P2PKH"):


Witness program: Hash160(public key)
redeemScript: OP_0 &lt;witness program&gt;
Script hash: Hash160(redeemScript)
scriptPubKey: OP_HASH160 &lt;script hash&gt; OP_EQUAL


P2WSH-P2PKH (native P2WSH, but with a P2PKH script inside):


Witness script: OP_DUP OP_HASH160 &lt;Hash160(pubkey)&gt; OP_EQUALVERIFY OP_CHECKSIG
Witness program: SHA256(witness script)
scriptPubKey: OP_0 &lt;witness program&gt;


Note that you should use P2WPKH instead of this.

Native P2WPKH


Witness program: Hash160(public key)
scriptPubKey: OP_0 &lt;witness program&gt;


Native P2WSH


Witness script: OP_3 &lt;public key1&gt; &lt;public key2&gt; &lt;public key3&gt; OP_2 OP_CHECKMULTISIG
Witness program: SHA256(witness script)
scriptPubKey: OP_0 &lt;witness program&gt;