Skip to content

Commit fb56a18

Browse files
committed
Specify BIP 382: Segwit descriptors
1 parent bd12ea7 commit fb56a18

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

README.mediawiki

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,13 @@ Those proposing changes should consider that ultimately consent may rest with th
10641064
| Pieter Wuille, Andrew Chow
10651065
| Informational
10661066
| Draft
1067+
|-
1068+
| [[bip-0382.mediawiki|382]]
1069+
| Applications
1070+
| Segwit Output Script Descriptors
1071+
| Pieter Wuille, Andrew Chow
1072+
| Informational
1073+
| Draft
10671074
|}
10681075

10691076
<!-- IMPORTANT! See the instructions at the top of this page, do NOT JUST add BIPs here! -->

bip-0380.mediawiki

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,10 @@ This Table lists all available Script expressions and the BIPs specifying them.
246246
|-
247247
| <tt>sh(SCRIPT)</tt>
248248
| [[bip-0381.mediawiki|381]]
249+
|-
250+
| <tt>wpkh(KEY)</tt>
251+
| [[bip-0382.mediawiki|382]]
252+
|-
253+
| <tt>wsh(SCRIPT)</tt>
254+
| [[bip-0382.mediawiki|382]]
249255
|}

bip-0381.mediawiki

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The output script produced is:
4646

4747
===<tt>pkh()</tt>===
4848

49-
The <tt>pkh(KEY)</tt> expression can be used as a top level expression, or inside of a <tt>sh()</tt> descriptor.
49+
The <tt>pkh(KEY)</tt> expression can be used as a top level expression, or inside of either a <tt>sh()</tt> or <tt>wsh()</tt> descriptor.
5050
It takes a single key expression as an argument and produces a P2PKH output script.
5151
Depending on the higher level descriptors, there may be restrictions on the type of public keys that can be included.
5252
Such restrictions will be specified by those descriptors.

bip-0382.mediawiki

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<pre>
2+
BIP: 382
3+
Layer: Applications
4+
Title: Segwit Output Script Descriptors
5+
Author: Pieter Wuille <[email protected]>
6+
Andrew Chow <[email protected]>
7+
Comments-Summary: No comments yet.
8+
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0382
9+
Status: Draft
10+
Type: Informational
11+
Created: 2021-06-27
12+
License: BSD-2-Clause
13+
</pre>
14+
15+
==Abstract==
16+
17+
This document specifies <tt>wpkh()</tt>, and <tt>wsh()</tt> output script descriptors.
18+
<tt>wpkh()</tt> descriptors take a key and produces a P2WPKH output script.
19+
<tt>wsh()</tt> descriptors take a script and produces a P2WSH output script.
20+
21+
==Copyright==
22+
23+
This BIP is licensed under the BSD 2-clause license.
24+
25+
==Motivation==
26+
27+
Segregated Witness added 2 additional standard output script formats: P2WPKH and P2WSH.
28+
These expressions allow specifying those formats as a descriptor.
29+
30+
==Specification==
31+
32+
Two new script expressions are defined: <tt>wpkh()</tt>, and <tt>wsh()</tt>.
33+
34+
===<tt>wpkh()</tt>===
35+
36+
The <tt>wpkh(KEY)</tt> expression can be used as a top level expression, or inside of a <tt>sh()</tt> descriptor.
37+
It takes a single key expression as an argument and produces a P2WPKH output script.
38+
Only keys which are/has compressed public keys can be contained in a <tt>wpkh()</tt> expression.
39+
40+
The output script produced is:
41+
<pre>
42+
OP_0 <KEY_hash160>
43+
</pre>
44+
45+
===<tt>wsh()</tt>===
46+
47+
The <tt>wsh(SCRIPT)</tt> expression can be used as a top level expression, or inside of a <tt>sh()</tt> descriptor.
48+
It takes a single script expression as an argument and produces a P2WSH output script.
49+
<tt>wsh()</tt> expressions also create a witnessScript which is required in order to spend outputs which use its output script.
50+
This redeemScript is the output script produced by the <tt>SCRIPT</tt> argument to <tt>wsh()</tt>.
51+
Any key expression found in any script expression contained by a <tt>wsh()</tt> expression must only produce compressed public keys.
52+
53+
The output script produced is:
54+
<pre>
55+
OP_0 <SCRIPT_sha256>
56+
</pre>
57+
58+
==Test Vectors==
59+
60+
TBD
61+
62+
==Backwards Compatibility==
63+
64+
<tt>wpkh()</tt>, and <tt>wsh()</tt> descriptors use the format and general operation specified in [[bip-0380.mediawiki|380]].
65+
As these are a wholly new descriptors, they are not compatible with any implementation.
66+
However the scripts produced are standard scripts so existing software are likely to be familiar with them.
67+
68+
==Reference Implemntation==
69+
70+
<tt>wpkh()</tt>, and <tt>wsh()</tt> descriptors have been implemented in Bitcoin Core since version 0.17.

0 commit comments

Comments
 (0)