<p>I thought it would be useful to have a text version of the image of a table in Michael Folkson's answer. If only for accessibility reasons.</p>
<p><sub>(it initially proved rather too hard to edit into his answer due to the table's markup complexity and stackexchange having different rendering of the edit preview and final answer!)</sub></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Output type</th>
<th>locking script</th>
<th>unlocking script</th>
<th>redeem script</th>
<th>witness</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>P2PK</strong></td>
<td>&lt;pubkey&gt;<br>OP_CHECKSIG</td>
<td>&lt;signature&gt;</td>
<td>—</td>
<td>—</td>
</tr>
<tr>
<td><strong>P2PKH</strong></td>
<td>OP_DUP<br>OP_HASH160<br>&lt;pubKeyHash&gt; OP_EQUALVERIFY<br>OP_CHECKSIG</td>
<td>&lt;signature&gt;<br>&lt;public key&gt;</td>
<td>—</td>
<td>—</td>
</tr>
<tr>
<td><strong>P2SH</strong></td>
<td>OP_HASH160<br>&lt;scripthash&gt;<br>OP_EQUAL</td>
<td>&lt;data pushes&gt;<br>&lt;redeem script&gt;</td>
<td>&lt;arbitrary&gt;</td>
<td>—</td>
</tr>
<tr>
<td><strong>P2WPKH</strong></td>
<td>0<br>&lt;pubKeyHash&gt;</td>
<td>—</td>
<td>—</td>
<td>&lt;signature&gt;<br>&lt;public key&gt;</td>
</tr>
<tr>
<td><strong>P2WSH</strong></td>
<td>0<br>&lt;witnessScriptHash&gt;</td>
<td>—</td>
<td>—</td>
<td>&lt;data pushes&gt;<br>&lt;witness script&gt;</td>
</tr>
<tr>
<td><strong>P2SH-P2WPKH</strong></td>
<td>OP_HASH160<br>&lt;redeemScriptHash&gt;<br>OP_EQUAL</td>
<td>&lt;redeem script&gt;</td>
<td>0<br>&lt;pubKeyHash&gt;</td>
<td>&lt;signature&gt;<br>&lt;public key&gt;</td>
</tr>
<tr>
<td><strong>P2SH-P2WSH</strong></td>
<td>OP_HASH160<br>&lt;redeemScriptHash&gt;<br>OP_EQUAL</td>
<td>&lt;redeem script&gt;</td>
<td>0<br>&lt;scriptHash&gt;</td>
<td>&lt;data pushes&gt;<br>&lt;witness script&gt;</td>
</tr>
<tr>
<td><strong>P2TR (key path)</strong></td>
<td>1<br>&lt;public key&gt;</td>
<td>—</td>
<td>—</td>
<td>&lt;signature&gt;</td>
</tr>
<tr>
<td><strong>P2TR (script path)</strong></td>
<td>1<br>&lt;public key&gt;</td>
<td>—</td>
<td>—</td>
<td>&lt;data pushes&gt;<br>&lt;script&gt;<br>&lt;control block&gt;</td>
</tr>
</tbody>
</table>
</div>
<p>Note that the redeem script for P2SH-P2WPKH is inside the unlocking script and its notation might be clearer as, for example <code>&lt;0 &lt;pubKeyHash&gt;&gt;</code> to show the nesting (&quot;wrapping&quot;) of the data pushes.</p>
<p>The serialisation of unlocking script <code>&lt;0 &lt;pubKeyHash&gt;&gt;</code> would be</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Hex</th>
<th>meaning</th>
<th>notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>16</td>
<td>push 22 byte wrapper</td>
<td>-</td>
</tr>
<tr>
<td>00</td>
<td>0</td>
<td>first wrapped item inside wrapper</td>
</tr>
<tr>
<td>14</td>
<td>push 20 byte pubKeyHash</td>
<td>-</td>
</tr>
<tr>
<td>...</td>
<td>pubKeyHash</td>
<td>second wrapped item inside same wrapper</td>
</tr>
</tbody>
</table>
</div>
<p>Essentially, the wrapped types (P2SH-P2W..) require recursive parsing, though only to depth 1, so maybe it shouldn't be regarded as recursive.</p>
<p>The table currently omits some interesting types such as multisig as well as some trivial types such as OP_RETURN.</p>

CC BY-SA 4.0
2023-10-03T11:41:48.540Z
2023-10-05T12:48:11.073Z
2023-10-05T12:48:11.073Z
RedGrittyBrick
<p>This was answered during the Bitcoin Core PR <a href="https://bitcoincore.reviews/22363" rel="nofollow noreferrer">review club</a> on July 7th 2021 hosted by Gloria Zhao (who also provided this table).</p>
<p><a href="https://i.sstatic.net/iXfVX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iXfVX.png" alt="enter image description here" /></a></p>
<p>The <code>&lt;public key&gt;</code> in the P2TR (key path) and P2TR (script path) scriptPubKey column is the tweaked public key rather than the internal key (assuming they aren't the same and the <a href="https://bitcoin.stackexchange.com/questions/99325/how-do-i-construct-a-p2tr-address-if-i-just-want-to-use-the-key-path">tweak</a> is being used as recommended by <a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_ref-23-0" rel="nofollow noreferrer">BIP 341</a>).</p>

CC BY-SA 4.0
2021-08-02T15:02:56.417Z
The first row should be labeled "P2PK".
Murch
CC BY-SA 4.0
2021-08-02T10:33:02.570Z
2023-08-21T10:36:20.413Z
2023-08-21T10:36:20.413Z
Michael Folkson
<p>scriptPubKey, redeem script, witness script, witness program are defined in this StackExchange <a href="https://bitcoin.stackexchange.com/questions/95231/redeem-script-script-hash-witness-script-and-witness-program/">post</a>.</p>
<p>What are the scriptPubKey, scriptSig, redeem script and witness for the various output types (P2PKH, P2SH, P2WPKH, P2WSH etc)?</p>

<script><p2sh><terminology><input-script><p2wpkh>
What are the scriptPubKey, scriptSig, redeem script and witness for the various output types?
Michael Folkson
# What are the scriptPubKey, scriptSig, redeem script and witness for the various output types?

(Asked by: username_0 on 2021-08-02)

scriptPubKey, redeem script, witness script, witness program are defined in this StackExchange [post](https://bitcoin.stackexchange.com/questions/95231/redeem-script-script-hash-witness-script-and-witness-program/).

What are the scriptPubKey, scriptSig, redeem script and witness for the various output types (P2PKH, P2SH, P2WPKH, P2WSH etc)?

**Tags:** script, p2sh, terminology, input-script, p2wpkh


---

## 2 answers

### Answer by username_0 on 2021-08-02. Score: 9 | Accepted answer

This was answered during the Bitcoin Core PR [review club](https://bitcoincore.reviews/22363) on July 7th 2021 hosted by Gloria Zhao (who also provided this table).

[![enter image description here](https://i.sstatic.net/iXfVX.png)](https://i.sstatic.net/iXfVX.png)

The `<public key>` in the P2TR (key path) and P2TR (script path) scriptPubKey column is the tweaked public key rather than the internal key (assuming they aren't the same and the [tweak](https://bitcoin.stackexchange.com/questions/99325/how-do-i-construct-a-p2tr-address-if-i-just-want-to-use-the-key-path) is being used as recommended by [BIP 341](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_ref-23-0)).

> **Comments:**
> **username_2**: The first row should be labeled "P2PK".  

---

### Answer by username_1 on 2023-10-03. Score: 3

I thought it would be useful to have a text version of the image of a table in username_0 username_0's answer. If only for accessibility reasons.

(it initially proved rather too hard to edit into his answer due to the table's markup complexity and stackexchange having different rendering of the edit preview and final answer!)

| Output type | locking script | unlocking script | redeem script | witness |
| --- | --- | --- | --- | --- |
| **P2PK** | <pubkey> OP\_CHECKSIG | <signature> | — | — |
| **P2PKH** | OP\_DUP OP\_HASH160 <pubKeyHash> OP\_EQUALVERIFY OP\_CHECKSIG | <signature> <public key> | — | — |
| **P2SH** | OP\_HASH160 <scripthash> OP\_EQUAL | <data pushes> <redeem script> | <arbitrary> | — |
| **P2WPKH** | 0 <pubKeyHash> | — | — | <signature> <public key> |
| **P2WSH** | 0 <witnessScriptHash> | — | — | <data pushes> <witness script> |
| **P2SH-P2WPKH** | OP\_HASH160 <redeemScriptHash> OP\_EQUAL | <redeem script> | 0 <pubKeyHash> | <signature> <public key> |
| **P2SH-P2WSH** | OP\_HASH160 <redeemScriptHash> OP\_EQUAL | <redeem script> | 0 <scriptHash> | <data pushes> <witness script> |
| **P2TR (key path)** | 1 <public key> | — | — | <signature> |
| **P2TR (script path)** | 1 <public key> | — | — | <data pushes> <script> <control block> |

Note that the redeem script for P2SH-P2WPKH is inside the unlocking script and its notation might be clearer as, for example `<0 <pubKeyHash>>` to show the nesting ("wrapping") of the data pushes.

The serialisation of unlocking script `<0 <pubKeyHash>>` would be

| Hex | meaning | notes |
| --- | --- | --- |
| 16 | push 22 byte wrapper | - |
| 00 | 0 | first wrapped item inside wrapper |
| 14 | push 20 byte pubKeyHash | - |
| ... | pubKeyHash | second wrapped item inside same wrapper |

Essentially, the wrapped types (P2SH-P2W..) require recursive parsing, though only to depth 1, so maybe it shouldn't be regarded as recursive.

The table currently omits some interesting types such as multisig as well as some trivial types such as OP\_RETURN.


---

