Skip to content

Commit cb7c401

Browse files
committed
Specify 389: Multipath descriptors
1 parent 43da5de commit cb7c401

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

bip-0389.mediawiki

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<pre>
2+
BIP: 389
3+
Layer: Applications
4+
Title: Multipath Descriptor Key Expressions
5+
Author: Andrew Chow <[email protected]>
6+
Comments-Summary: No comments yet.
7+
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-multipath-descs
8+
Status: Draft
9+
Type: Informational
10+
Created: 2022-07-26
11+
License: BSD-2-Clause
12+
</pre>
13+
14+
==Abstract==
15+
16+
This document specifies a modification to Key Expressions of Descriptors that are described in BIP 380.
17+
This modification allows Key Expressions to indicate BIP 32 derivation path steps that can have multiple values.
18+
19+
==Copyright==
20+
21+
This BIP is licensed under the BSD 2-clause license.
22+
23+
==Motivation==
24+
25+
Descriptors can describe the scripts that are used in a wallet, but wallets often require at least two descriptors for all of the scripts that they watch for.
26+
Wallets typically have one descriptor for producing receiving addresses, and the other for change addresses.
27+
These descriptors are often extremely similar - they produce the same types of scripts, derive keys from the same master key, and use derivation paths that are almost identical.
28+
The only differences are in the derivation path where one of the steps will be different between the descriptors.
29+
Thus it is useful to have a notation to represent both descriptors as a single descriptor where one of the derivation steps is a pair of values.
30+
31+
==Specification==
32+
33+
For extended keys and their derivations paths in a Key Expression, BIP 380 states:
34+
35+
* <tt>xpub</tt> encoded extended public key or <tt>xprv</tt> encoded extended private key (as defined in BIP 32)
36+
** Followed by zero or more <tt>/NUM</tt> or <tt>/NUMh</tt> path elements indicating BIP 32 derivation steps to be taken after the given extended key.
37+
** Optionally followed by a single <tt>/*</tt> or <tt>/*h</tt> final step to denote all direct unhardened or hardened children.
38+
39+
This is modifed to state:
40+
41+
* <tt>xpub</tt> encoded extended public key or <tt>xprv</tt> encoded extended private key (as defined in BIP 32)
42+
** Followed by zero or more <tt>/NUM</tt> or <tt>/NUMh</tt> path elements indicating BIP 32 derivation steps to be taken after the given extended key.
43+
** Followed by zero or one <tt>/<NUM;NUM</tt> (<tt>NUM</tt> may be followed by <tt>h</tt>, <tt>H</tt>, or <tt>'</tt> to indicate a hardened step) path element indicating a tuple of BIP 32 derivation steps to be taken after the given extended key.
44+
*** Followed by zero or more <tt>;NUM</tt> or <tt>;NUMh</tt> additional tuple values of BIP 32 derivation steps
45+
*** Followed by a single <tt>></tt>
46+
** Followed by zero or more <tt>/NUM</tt> or <tt>/NUMh</tt> path elements indicating BIP 32 derivation steps to be taken after the given extended key.
47+
** Optionally followed by a single <tt>/*</tt> or <tt>/*h</tt> final step to denote all direct unhardened or hardened children.
48+
49+
When a <tt>/<NUM;NUM;...;NUM></tt> is encountered, parsers should produce multiple descriptors where the first descriptor uses the first <tt>NUM</tt>, and a second descriptor uses the second <tt>NUM</tt>, and so on, until each <tt>NUM</tt> is accounted for.
50+
Descriptors that contain multiple Key Expressions that each have a <tt>/<NUM;NUM;...;NUM></tt> must have tuples of exactly the same length.
51+
52+
The common use case for this is to represent descriptors for producing receiving and change addresses.
53+
When interpreting for this use case, wallets should use the first descriptor for producing receiving addresses, and the second descriptor for producing change addresses.
54+
For this use case, the element will commonly be the value <tt>/<0;1></tt>
55+
56+
Note that only one <tt>/<NUM;NUM;...;NUM></tt> specifier is allowed in a Key Expression.
57+
This is in contrast to proposals such as BIP 88 which allow for multiple derivation indexes in a single element.
58+
This limitation exists in order to reduce the number of descriptors that are expanded, avoid confusion about how to expand the descriptor, and avoid having expanded descriptors that users are not expecting.
59+
60+
==Test Vectors==
61+
62+
TBD
63+
64+
==Backwards Compatibility==
65+
66+
This is an addition to the Key Expressions defined in BIP 380.
67+
Key Expressions using the format described in BIP 380 are compatible with this modification and parsers that implement this will still be able to parse such descriptors.
68+
However as this is an addition to Key Expressions, older parsers will not be able to understand such descriptors.
69+
70+
This modification to Key Expressions uses two new characters: <tt><</tt> and <tt>;</tt>.
71+
These are part of the descriptor character set and so are covered by the checksum algorithm.
72+
As these are previously unused characters, old parsers will not accidentally mistake them for indicating something else.
73+
74+
==Reference Implementation==
75+
76+
https://github.com/bitcoin/bitcoin/pull/22838

0 commit comments

Comments
 (0)