{"number":382,"title":"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 wpkh() , and wsh() output script descriptors. wpkh() descriptors take a key and produces a P2WPKH output script. wsh() descriptors take a script and produces a P2WSH output script.","eli5":"Defines the descriptor functions for native SegWit outputs, covering both single-key addresses and script-based ones. With these, wallets can precisely describe and back up SegWit wallets, including multisig setups.","categories":["wallets"],"filename":"bip-0382.mediawiki","githubUrl":"https://github.com/bitcoin/bips/blob/master/bip-0382.mediawiki","format":"mediawiki","readingMinutes":2,"inbound":3,"revisions":13,"impact":77,"core":false,"references":[],"lastModified":"2026-09-17","html":"<h2 id=\"abstract\">Abstract</h2>\n<p>This document specifies <code>wpkh()</code>, and <code>wsh()</code> output script descriptors. <code>wpkh()</code> descriptors take a key and produces a P2WPKH output script. <code>wsh()</code> descriptors take a script and produces a P2WSH 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>Segregated Witness added 2 additional standard output script formats: P2WPKH and P2WSH. These expressions allow specifying those formats as a descriptor.</p>\n<h2 id=\"specification\">Specification</h2>\n<p>Two new script expressions are defined: <code>wpkh()</code>, and <code>wsh()</code>.</p>\n<h3 id=\"wpkh\"><code>wpkh()</code></h3>\n<p>The <code>wpkh(KEY)</code> expression can be used as a top level expression, or inside of a <code>sh()</code> descriptor. It takes a single key expression as an argument and produces a P2WPKH output script. Only keys which are/have compressed public keys can be contained in a <code>wpkh()</code> expression.</p>\n<p>The output script produced is:</p>\n<pre><code>OP_0 &lt;KEY_hash160&gt;</code></pre>\n<h3 id=\"wsh\"><code>wsh()</code></h3>\n<p>The <code>wsh(SCRIPT)</code> expression can be used as a top level expression, or inside of a <code>sh()</code> descriptor. It takes a single script expression as an argument and produces a P2WSH output script. <code>wsh()</code> expressions also create a witnessScript 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>wsh()</code>. Any key expression found in any script expression contained by a <code>wsh()</code> expression must only produce compressed public keys.</p>\n<p>The output script produced is:</p>\n<pre><code>OP_0 &lt;SCRIPT_sha256&gt;</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>wpkh(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1)</code>\n<ul><li>\n<code>00149a1c78a507689f6f54b847ad1cef1e614ee23f1e</code>\n</li></ul>\n</li><li>\n<code>wpkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</code>\n<ul><li>\n<code>00149a1c78a507689f6f54b847ad1cef1e614ee23f1e</code>\n</li></ul>\n</li><li>\n<code>wpkh([ffffffff/13']xprv9vHkqa6EV4sPZHYqZznhT2NPtPCjKuDKGY38FBWLvgaDx45zo9WQRUT3dKYnjwih2yJD9mkrocEZXo1ex8G81dwSM1fwqWpWkeS3v86pgKt/1/2/0)</code>\n<ul><li>\n<code>0014326b2249e3a25d5dc60935f044ee835d090ba859</code>\n</li></ul>\n</li><li>\n<code>wpkh([ffffffff/13']xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/1/2/*)</code>\n<ul><li>\n<code>0014326b2249e3a25d5dc60935f044ee835d090ba859</code>\n</li></ul>\n<ul><li>\n<code>0014af0bd98abc2f2cae66e36896a39ffe2d32984fb7</code>\n</li></ul>\n<ul><li>\n<code>00141fa798efd1cbf95cebf912c031b8a4a6e9fb9f27</code>\n</li></ul>\n</li><li>\n<code>sh(wpkh(xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi/10/20/30/40/*'))</code>\n<ul><li>\n<code>a9149a4d9901d6af519b2a23d4a2f51650fcba87ce7b87</code>\n</li></ul>\n<ul><li>\n<code>a914bed59fc0024fae941d6e20a3b44a109ae740129287</code>\n</li></ul>\n<ul><li>\n<code>a9148483aa1116eb9c05c482a72bada4b1db24af654387</code>\n</li></ul>\n</li><li>\n<code>sh(wpkh(xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi/10/20/30/40/*h))</code>\n<ul><li>\n<code>a9149a4d9901d6af519b2a23d4a2f51650fcba87ce7b87</code>\n</li></ul>\n<ul><li>\n<code>a914bed59fc0024fae941d6e20a3b44a109ae740129287</code>\n</li></ul>\n<ul><li>\n<code>a9148483aa1116eb9c05c482a72bada4b1db24af654387</code>\n</li></ul>\n</li><li>\n<code>wsh(pkh(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1))</code>\n<ul><li>\n<code>0020338e023079b91c58571b20e602d7805fb808c22473cbc391a41b1bd3a192e75b</code>\n</li></ul>\n</li><li>\n<code>wsh(pkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n<ul><li>\n<code>0020338e023079b91c58571b20e602d7805fb808c22473cbc391a41b1bd3a192e75b</code>\n</li></ul>\n</li><li>\n<code>wsh(pk(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1))</code>\n<ul><li>\n<code>00202e271faa2325c199d25d22e1ead982e45b64eeb4f31e73dbdf41bd4b5fec23fa</code>\n</li></ul>\n</li><li>\n<code>wsh(pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n<ul><li>\n<code>00202e271faa2325c199d25d22e1ead982e45b64eeb4f31e73dbdf41bd4b5fec23fa</code>\n</li></ul>\n</li><li>\n<code>sh(wsh(pkh(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1)))</code>\n<ul><li>\n<code>a914b61b92e2ca21bac1e72a3ab859a742982bea960a87</code>\n</li></ul>\n</li><li>\n<code>sh(wsh(pkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)))</code>\n<ul><li>\n<code>a914b61b92e2ca21bac1e72a3ab859a742982bea960a87</code>\n</li></ul>\n</li></ul>\n<p>Invalid descriptors with descriptions</p>\n<ul><li>\nUncompressed public key in <code>wpkh()</code>: <code>wpkh(5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss)</code>\n</li></ul>\n<ul><li>\nUncompressed public key in <code>wpkh()</code>: <code>sh(wpkh(5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss))</code>\n</li></ul>\n<ul><li>\nUncompressed public key in <code>wpkh()</code>: <code>wpkh(04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235)</code>\n</li></ul>\n<ul><li>\nUncompressed public key in <code>wpkh()</code>: <code>sh(wpkh(04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235))</code>\n</li></ul>\n<ul><li>\nUncompressed public keys under <code>wsh()</code>: <code>wsh(pk(5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss))</code>\n</li></ul>\n<ul><li>\nUncompressed public keys under <code>wsh()</code>: <code>wsh(pk(04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235))</code>\n</li></ul>\n<ul><li>\n<code>wpkh()</code> nested in <code>wsh()</code>: <code>wsh(wpkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n</li></ul>\n<ul><li>\n<code>wsh()</code> nested in <code>wsh()</code>: <code>wsh(wsh(pkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)))</code>\n</li></ul>\n<ul><li>\n<code>wsh()</code> nested in <code>wsh()</code>: <code>sh(wsh(wsh(pkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))))</code>\n</li></ul>\n<ul><li>\nScript in <code>wpkh()</code>: <code>wpkh(wsh(pkh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)))</code>\n</li></ul>\n<ul><li>\nKey in <code>wsh()</code>: <code>wsh(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)</code>\n</li></ul>\n<h2 id=\"backwards-compatibility\">Backwards Compatibility</h2>\n<p><code>wpkh()</code>, and <code>wsh()</code> descriptors use the format and general operation specified in <a href=\"/bip/380\">380</a>. As these are a 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>wpkh()</code>, and <code>wsh()</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":"wpkh","title":"wpkh()","level":3},{"id":"wsh","title":"wsh()","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":13,"firstCommit":"2021-06-27T19:35:45-04:00","lastUpdated":"2026-09-17T15:02:52+02:00","events":[{"sha":"a31ee298c4a609ba40a67f9ba5abc86d300f4050","date":"2026-09-17T15:02:52+02:00","author":"Daniela Brozzoni","message":"bip382: Update to Specification type","url":"https://github.com/bitcoin/bips/commit/a31ee298c4a609ba40a67f9ba5abc86d300f4050","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":"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":"8795003831279c9af60f4a32bbc4af8b4b19cbc0","date":"2024-04-03T10:02:10-05:00","author":"Chris Stewart","message":"Fix unsatisfiable test vector in BIP382","url":"https://github.com/bitcoin/bips/commit/8795003831279c9af60f4a32bbc4af8b4b19cbc0","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"}]}}