{"number":381,"title":"Non-Segwit Output Script Descriptors","authors":["Pieter Wuille","Ava Chow"],"status":"Deployed","type":"Specification","layer":"Applications","created":"2021-06-27","license":"BSD-2-Clause","requires":[380],"replaces":[],"replacedBy":[],"discussion":[],"abstract":"This document specifies pk() , pkh() , and sh() output script descriptors. pk() descriptors take a key and produces a P2PK output script. pkh() descriptors take a key and produces a P2PKH output script. sh() descriptors take a script and produces a P2SH output script.","eli5":"Defines the descriptor functions for Bitcoin's older address types: pay-to-public-key, pay-to-public-key-hash (classic addresses starting with '1'), and pay-to-script-hash (addresses starting with '3'). This lets descriptor-based wallets describe and recover coins held in these legacy formats.","categories":["encoding"],"filename":"bip-0381.mediawiki","githubUrl":"https://github.com/bitcoin/bips/blob/master/bip-0381.mediawiki","format":"mediawiki","readingMinutes":2,"inbound":2,"revisions":15,"impact":67,"core":false,"references":[],"lastModified":"2026-09-17","html":"<h2 id=\"abstract\">Abstract</h2>\n<p>This document specifies <code>pk()</code>, <code>pkh()</code>, and <code>sh()</code> output script descriptors. <code>pk()</code> descriptors take a key and produces a P2PK output script. <code>pkh()</code> descriptors take a key and produces a P2PKH output script. <code>sh()</code> descriptors take a script and produces a P2SH output script.</p>\n<h2 id=\"copyright\">Copyright</h2>\n<p>This BIP is licensed under the BSD 2-clause license.</p>\n<h2 id=\"motivation\">Motivation</h2>\n<p>Prior to the activation of Segregated Witness, there were 3 main standard output script formats: P2PK, P2PKH, and P2SH. These expressions allow specifying those formats as a descriptor.</p>\n<h2 id=\"specification\">Specification</h2>\n<p>Three new script expressions are defined: <code>pk()</code>, <code>pkh()</code>, and <code>sh()</code>.</p>\n<h3 id=\"pk\"><code>pk()</code></h3>\n<p>The <code>pk(KEY)</code> expression can be used in any context or level of a descriptor. It takes a single key expression as an argument and produces a P2PK output script. Depending on the higher level descriptors, there may be restrictions on the type of public keys that can be included. Such restrictions will be specified by those descriptors.</p>\n<p>The output script produced is:</p>\n<pre><code>&lt;KEY&gt; OP_CHECKSIG</code></pre>\n<h3 id=\"pkh\"><code>pkh()</code></h3>\n<p>The <code>pkh(KEY)</code> expression can be used as a top level expression, or inside of either a <code>sh()</code> or <code>wsh()</code> descriptor. It takes a single key expression as an argument and produces a P2PKH output script. Depending on the higher level descriptors, there may be restrictions on the type of public keys that can be included. Such restrictions will be specified by those descriptors.</p>\n<p>The output script produced is:</p>\n<pre><code>OP_DUP OP_HASH160 &lt;KEY_hash160&gt; OP_EQUALVERIFY OP_CHECKSIG</code></pre>\n<h3 id=\"sh\"><code>sh()</code></h3>\n<p>The <code>sh(SCRIPT)</code> expression can only be used as a top level expression. It takes a single script expression as an argument and produces a P2SH output script. <code>sh()</code> expressions also create a redeemScript which is required in order to spend outputs which use its output script. This redeemScript is the output script produced by the <code>SCRIPT</code> argument to <code>sh()</code>.</p>\n<p>The output script produced is:</p>\n<pre><code>OP_HASH160 &lt;SCRIPT_hash160&gt; OP_EQUAL</code></pre>\n<h2 id=\"test-vectors\">Test Vectors</h2>\n<p>Valid descriptors followed by the scripts they produce. Descriptors involving derived child keys will have the 0th, 1st, and 2nd scripts listed.</p>\n<ul><li>\n<code>pk(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1)</code>\n<ul><li>\n<code>2103a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bdac</code>\n</li></ul>\n</li><li>\n<code>pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</code>\n<ul><li>\n<code>2103a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bdac</code>\n</li></ul>\n</li><li>\n<code>pkh([deadbeef/1/2'/3/4']L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1)</code>\n<ul><li>\n<code>76a9149a1c78a507689f6f54b847ad1cef1e614ee23f1e88ac</code>\n</li></ul>\n</li><li>\n<code>pkh([deadbeef/1/2'/3/4']03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</code>\n<ul><li>\n<code>76a9149a1c78a507689f6f54b847ad1cef1e614ee23f1e88ac</code>\n</li></ul>\n</li><li>\n<code>pkh([deadbeef/1/2h/3/4h]03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</code>\n<ul><li>\n<code>76a9149a1c78a507689f6f54b847ad1cef1e614ee23f1e88ac</code>\n</li></ul>\n</li><li>\n<code>pk(5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss)</code>\n<ul><li>\n<code>4104a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235ac</code>\n</li></ul>\n</li><li>\n<code>pk(04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235)</code>\n<ul><li>\n<code>4104a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235ac</code>\n</li></ul>\n</li><li>\n<code>pkh(5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss)</code>\n<ul><li>\n<code>76a914b5bd079c4d57cc7fc28ecf8213a6b791625b818388ac</code>\n</li></ul>\n</li><li>\n<code>pkh(04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235)</code>\n<ul><li>\n<code>76a914b5bd079c4d57cc7fc28ecf8213a6b791625b818388ac</code>\n</li></ul>\n</li><li>\n<code>sh(pk(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1))</code>\n<ul><li>\n<code>a9141857af51a5e516552b3086430fd8ce55f7c1a52487</code>\n</li></ul>\n</li><li>\n<code>sh(pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n<ul><li>\n<code>a9141857af51a5e516552b3086430fd8ce55f7c1a52487</code>\n</li></ul>\n</li><li>\n<code>sh(pkh(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1))</code>\n<ul><li>\n<code>a9141a31ad23bf49c247dd531a623c2ef57da3c400c587</code>\n</li></ul>\n</li><li>\n<code>sh(pkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n<ul><li>\n<code>a9141a31ad23bf49c247dd531a623c2ef57da3c400c587</code>\n</li></ul>\n</li><li>\n<code>pkh(xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U/2147483647'/0)</code>\n<ul><li>\n<code>76a914ebdc90806a9c4356c1c88e42216611e1cb4c1c1788ac</code>\n</li></ul>\n</li><li>\n<code>pkh([bd16bee5/2147483647h]xpub69H7F5dQzmVd3vPuLKtcXJziMEQByuDidnX3YdwgtNsecY5HRGtAAQC5mXTt4dsv9RzyjgDjAQs9VGVV6ydYCHnprc9vvaA5YtqWyL6hyds/0)</code>\n<ul><li>\n<code>76a914ebdc90806a9c4356c1c88e42216611e1cb4c1c1788ac</code>\n</li></ul>\n</li><li>\n<code>pk(xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L/0)</code>\n<ul><li>\n<code>210379e45b3cf75f9c5f9befd8e9506fb962f6a9d185ac87001ec44a8d3df8d4a9e3ac</code>\n</li></ul>\n</li><li>\n<code>pk(xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0)</code>\n<ul><li>\n<code>210379e45b3cf75f9c5f9befd8e9506fb962f6a9d185ac87001ec44a8d3df8d4a9e3ac</code>\n</li></ul>\n</li></ul>\n<p>Invalid descriptors</p>\n<ul><li>\n<code>pk()</code> only accepts key expressions: <code>pk(pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n</li></ul>\n<ul><li>\n<code>pkh()</code> only accepts key expressions: <code>pkh(pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n</li></ul>\n<ul><li>\n<code>sh()</code> only accepts script expressions: <code>sh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</code>\n</li></ul>\n<ul><li>\n<code>sh()</code> is top level only: <code>sh(sh(pkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)))</code>\n</li></ul>\n<h2 id=\"backwards-compatibility\">Backwards Compatibility</h2>\n<p><code>pk()</code>, <code>pkh()</code>, and <code>sh()</code> descriptors use the format and general operation specified in <a href=\"/bip/380\">380</a>. As these are wholly new descriptors, they are not compatible with any implementation. However the scripts produced are standard scripts so existing software are likely to be familiar with them.</p>\n<h2 id=\"reference-implementation\">Reference Implementation</h2>\n<p><code>pk()</code>, <code>pkh()</code>, and <code>sh()</code> descriptors have been implemented in Bitcoin Core since version 0.17.</p>","toc":[{"id":"abstract","title":"Abstract","level":2},{"id":"copyright","title":"Copyright","level":2},{"id":"motivation","title":"Motivation","level":2},{"id":"specification","title":"Specification","level":2},{"id":"pk","title":"pk()","level":3},{"id":"pkh","title":"pkh()","level":3},{"id":"sh","title":"sh()","level":3},{"id":"test-vectors","title":"Test Vectors","level":2},{"id":"backwards-compatibility","title":"Backwards Compatibility","level":2},{"id":"reference-implementation","title":"Reference Implementation","level":2}],"history":{"totalCommits":15,"firstCommit":"2021-06-27T18:49:37-04:00","lastUpdated":"2026-09-17T15:02:33+02:00","events":[{"sha":"66dbdb47101c9db105abffb4e449f9be0f1fd13b","date":"2026-09-17T15:02:33+02:00","author":"Daniela Brozzoni","message":"bip381: Update to Specification type","url":"https://github.com/bitcoin/bips/commit/66dbdb47101c9db105abffb4e449f9be0f1fd13b","kind":"edit"},{"sha":"24e96e870fffaa257b465ce1f0370c14aac588e8","date":"2025-10-08T14:59:36-07:00","author":"Murch","message":"process: Created ↦ Assigned","url":"https://github.com/bitcoin/bips/commit/24e96e870fffaa257b465ce1f0370c14aac588e8","kind":"edit"},{"sha":"5207ef92a52d0b8902895b0dbb40823a4d698ec9","date":"2025-04-11T20:08:17-07:00","author":"Murch","message":"process: Author ↦ Authors","url":"https://github.com/bitcoin/bips/commit/5207ef92a52d0b8902895b0dbb40823a4d698ec9","kind":"edit"},{"sha":"59730dec4fb641a41589aa1b91d3c452f13e0e36","date":"2025-04-11T20:05:13-07:00","author":"Murch","message":"process: Remove Comments-URI and -Summary","url":"https://github.com/bitcoin/bips/commit/59730dec4fb641a41589aa1b91d3c452f13e0e36","kind":"edit"},{"sha":"5d3ceb37734f80b2ec206fc94245e3bfd6d5b0f0","date":"2025-04-11T18:08:44-07:00","author":"Murch","message":"process: Final/Active ↦ Deployed","url":"https://github.com/bitcoin/bips/commit/5d3ceb37734f80b2ec206fc94245e3bfd6d5b0f0","kind":"status"},{"sha":"bc66fdb1664781eacfa23c9077f268eb918103e2","date":"2025-06-18T14:56:02-07:00","author":"Ava Chow","message":"descriptors: Require BIP 380","url":"https://github.com/bitcoin/bips/commit/bc66fdb1664781eacfa23c9077f268eb918103e2","kind":"edit"},{"sha":"1447ab990d0a1493cf6be2438620a32ba30fc4e2","date":"2025-04-11T22:01:50+02:00","author":"kilavvy","message":"BIP381, 382: minor grammar fixups (#1816)","url":"https://github.com/bitcoin/bips/commit/1447ab990d0a1493cf6be2438620a32ba30fc4e2","kind":"edit"},{"sha":"450cdbbdafaac3bc5a53d546363dda87562d06e1","date":"2024-12-17T05:30:45+01:00","author":"Huberto","message":"BIP372, BIP381: trivial spelling fixups","url":"https://github.com/bitcoin/bips/commit/450cdbbdafaac3bc5a53d546363dda87562d06e1","kind":"edit"},{"sha":"d71428ade56ad9a90e18d643eefefefb6088fbd7","date":"2024-07-10T19:02:19-04:00","author":"Ava Chow","message":"380-387: Mark basic descriptor BIPs as final","url":"https://github.com/bitcoin/bips/commit/d71428ade56ad9a90e18d643eefefefb6088fbd7","kind":"status"},{"sha":"8a9e5744140222a4be238bbaa78f2512cf0102b5","date":"2024-04-03T15:00:42-05:00","author":"Chris Stewart","message":"Fix unsatisfiable test vector in BIP381","url":"https://github.com/bitcoin/bips/commit/8a9e5744140222a4be238bbaa78f2512cf0102b5","kind":"edit"},{"sha":"a28b021b9933cb6b035cbb94fc1a15c30da3f6fd","date":"2023-12-13T11:12:08-05:00","author":"Ava Chow","message":"Update contact info for achow101","url":"https://github.com/bitcoin/bips/commit/a28b021b9933cb6b035cbb94fc1a15c30da3f6fd","kind":"edit"},{"sha":"bb562aa8e9c438e653668b08e5c16b7e71abc832","date":"2023-06-29T16:15:14-04:00","author":"Andrew Chow","message":"descriptors: add test vectors","url":"https://github.com/bitcoin/bips/commit/bb562aa8e9c438e653668b08e5c16b7e71abc832","kind":"edit"},{"sha":"7007dbac006b8979c352f336039a47ffe32671c5","date":"2021-09-15T09:21:09-03:00","author":"jaonoctus","message":"typo: BIP [380-385]","url":"https://github.com/bitcoin/bips/commit/7007dbac006b8979c352f336039a47ffe32671c5","kind":"edit"},{"sha":"fb56a18c890af8b269987b2e6664765ffc05a5c1","date":"2021-06-27T19:35:45-04:00","author":"Andrew Chow","message":"Specify BIP 382: Segwit descriptors","url":"https://github.com/bitcoin/bips/commit/fb56a18c890af8b269987b2e6664765ffc05a5c1","kind":"edit"},{"sha":"bd12ea7e9ddde4c7bd70bf3c4e13e98f941fcc4d","date":"2021-06-27T18:49:37-04:00","author":"Andrew Chow","message":"Specify BIP 381: Non-segwit descriptors","url":"https://github.com/bitcoin/bips/commit/bd12ea7e9ddde4c7bd70bf3c4e13e98f941fcc4d","kind":"edit"}]}}