Skip to content

Commit bd12ea7

Browse files
committed
Specify BIP 381: Non-segwit descriptors
1 parent 71f435e commit bd12ea7

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

README.mediawiki

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,13 @@ Those proposing changes should consider that ultimately consent may rest with th
10571057
| Pieter Wuille, Andrew Chow
10581058
| Informational
10591059
| Draft
1060+
|-
1061+
| [[bip-0381.mediawiki|381]]
1062+
| Applications
1063+
| Non-Segwit Output Script Descriptors
1064+
| Pieter Wuille, Andrew Chow
1065+
| Informational
1066+
| Draft
10601067
|}
10611068

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

bip-0380.mediawiki

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,12 @@ This Table lists all available Script expressions and the BIPs specifying them.
238238
! Expression
239239
! BIP
240240
|-
241+
| <tt>pk(KEY)</tt>
242+
| [[bip-0381.mediawiki|381]]
243+
|-
244+
| <tt>pkh(KEY)</tt>
245+
| [[bip-0381.mediawiki|381]]
246+
|-
247+
| <tt>sh(SCRIPT)</tt>
248+
| [[bip-0381.mediawiki|381]]
241249
|}

bip-0381.mediawiki

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<pre>
2+
BIP: 381
3+
Layer: Applications
4+
Title: Non-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-0381
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>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt> output script descriptors.
18+
<tt>pk()</tt> descriptors take a key and produces a P2PK output script.
19+
<tt>pkh()</tt> descriptors take a key and produces a P2PKH output script.
20+
<tt>sh()</tt> descriptors take a script and produces a P2SH output script.
21+
22+
==Copyright==
23+
24+
This BIP is licensed under the BSD 2-clause license.
25+
26+
==Motivation==
27+
28+
Prior to the activation of Segregated Witness, there were 3 main standard output script formats: P2PK, P2PKH, and P2SH.
29+
These expressions allow specifying those formats as a descriptor.
30+
31+
==Specification==
32+
33+
Three new script expressions are defined: <tt>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt>.
34+
35+
===<tt>pk()</tt>===
36+
37+
The <tt>pk(KEY)</tt> expression can be used in any context or level of a descriptor.
38+
It takes a single key expression as an argument and produces a P2PK output script.
39+
Depending on the higher level descriptors, there may be restrictions on the type of public keys that can be included.
40+
Such restrictions will be specified by those descriptors.
41+
42+
The output script produced is:
43+
<pre>
44+
<KEY> OP_CHECKSIG
45+
</pre>
46+
47+
===<tt>pkh()</tt>===
48+
49+
The <tt>pkh(KEY)</tt> expression can be used as a top level expression, or inside of a <tt>sh()</tt> descriptor.
50+
It takes a single key expression as an argument and produces a P2PKH output script.
51+
Depending on the higher level descriptors, there may be restrictions on the type of public keys that can be included.
52+
Such restrictions will be specified by those descriptors.
53+
54+
The output script produced is:
55+
<pre>
56+
OP_DUP OP_HASH160 <KEY_hash160> OP_EQUALVERIFY OP_CHECKSIG
57+
</pre>
58+
59+
===<tt>sh()</tt>===
60+
61+
The <tt>sh(SCRIPT)</tt> expression can only be used as a top level expression.
62+
It takes a single script expression as an argument and produces a P2SH output script.
63+
<tt>sh()</tt> expressions also create a redeemScript which is required in order to spend outputs which use its output script.
64+
This redeemScript is the output script produced by the <tt>SCRIPT</tt> argument to <tt>sh()</tt>.
65+
66+
The output script produced is:
67+
<pre>
68+
OP_HASH160 <SCRIPT_hash160> OP_EQUAL
69+
</pre>
70+
71+
==Test Vectors==
72+
73+
TBD
74+
75+
==Backwards Compatibility==
76+
77+
<tt>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt> descriptors use the format and general operation specified in [[bip-0380.mediawiki|380]].
78+
As these are a wholly new descriptors, they are not compatible with any implementation.
79+
However the scripts produced are standard scripts so existing software are likely to be familiar with them.
80+
81+
==Reference Implemntation==
82+
83+
<tt>pk()</tt>, <tt>pkh()</tt>, and <tt>sh()</tt> descriptors have been implemented in Bitcoin Core since version 0.17.

0 commit comments

Comments
 (0)