You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/descriptors.md
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,19 +59,20 @@ Descriptors consist of several types of expressions. The top level expression is
59
59
- Followed by zero or more `/NUM` or `/NUM'` path elements to indicate unhardened or hardened derivation steps between the fingerprint and the key or xpub/xprv root that follows
60
60
- A closing bracket `]`
61
61
- Followed by the actual key, which is either:
62
-
- Hex encoded public keys (66 characters starting with `02` or `03`, or 130 characters starting with `04`).
62
+
- Hex encoded public keys (either 66 characters starting with `02` or `03` for a compressed pubkey, or 130 characters starting with `04` for an uncompressed pubkey).
63
63
- Inside `wpkh` and `wsh`, only compressed public keys are permitted.
64
64
-[WIF](https://en.bitcoin.it/wiki/Wallet_import_format) encoded private keys may be specified instead of the corresponding public key, with the same meaning.
65
-
-`xpub` encoded extended public key or `xprv` encoded private key (as defined in [BIP 32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)).
65
+
-`xpub` encoded extended public key or `xprv` encoded extended private key (as defined in [BIP 32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)).
66
66
- Followed by zero or more `/NUM` unhardened and `/NUM'` hardened BIP32 derivation steps.
67
67
- Optionally followed by a single `/*` or `/*'` final step to denote all (direct) unhardened or hardened children.
68
68
- The usage of hardened derivation steps requires providing the private key.
69
-
- Anywhere a `'` suffix is permitted to denote hardened derivation, the suffix `h` can be used instead.
69
+
70
+
(Anywhere a `'` suffix is permitted to denote hardened derivation, the suffix `h` can be used instead.)
70
71
71
72
`ADDR` expressions are any type of supported address:
72
-
- P2PKH addresses (base58, of the form `1...`). Note that P2PKH addresses in descriptors cannot be used for P2PK outputs (use the `pk` function instead).
73
-
- P2SH addresses (base58, of the form `3...`, defined in [BIP 13](https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki)).
74
-
- Segwit addresses (bech32, of the form `bc1...`, defined in [BIP 173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki)).
73
+
- P2PKH addresses (base58, of the form `1...` for mainnet or `[nm]...` for testnet). Note that P2PKH addresses in descriptors cannot be used for P2PK outputs (use the `pk` function instead).
74
+
- P2SH addresses (base58, of the form `3...` for mainnet or `2...` for testnet, defined in [BIP 13](https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki)).
75
+
- Segwit addresses (bech32, of the form `bc1...` for mainnet or `tb1...` for testnet, defined in [BIP 173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki)).
75
76
76
77
## Explanation
77
78
@@ -83,10 +84,9 @@ imaginable, though they may not be optimal: P2SH-P2PK, P2SH-P2PKH,
To describe these, we model these as functions. The functions `pk`
86
-
(P2PK), `pkh` (P2PKH) and `wpkh` (P2WPKH) take as input a public key in
87
-
hexadecimal notation (which will be extended later), and return the
87
+
(P2PK), `pkh` (P2PKH) and `wpkh` (P2WPKH) take as input a `KEY` expression, and return the
88
88
corresponding *scriptPubKey*. The functions `sh` (P2SH) and `wsh` (P2WSH)
89
-
take as input a script, and return the script describing P2SH and P2WSH
89
+
take as input a `SCRIPT` expression, and return the script describing P2SH and P2WSH
90
90
outputs with the input as embedded script. The names of the functions do
91
91
not contain "p2" for brevity.
92
92
@@ -95,7 +95,7 @@ not contain "p2" for brevity.
95
95
Several pieces of software use multi-signature (multisig) scripts based
96
96
on Bitcoin's OP_CHECKMULTISIG opcode. To support these, we introduce the
97
97
`multi(k,key_1,key_2,...,key_n)` function. It represents a *k-of-n*
98
-
multisig policy, where any *k* out of the *n* provided public keys must
98
+
multisig policy, where any *k* out of the *n* provided `KEY` expressions must
99
99
sign.
100
100
101
101
Key order is significant. A `multi()` expression describes a multisig script
@@ -138,7 +138,7 @@ Instead, it should be written as `xpub.../1/*`, where xpub corresponds to
138
138
`m/44'/0'/0'`.
139
139
140
140
When interacting with a hardware device, it may be necessary to include
141
-
the entire path from the master down. BIP174 standardizes this by
141
+
the entire path from the master down. [BIP174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) standardizes this by
142
142
providing the master key *fingerprint* (first 32 bit of the Hash160 of
143
143
the master pubkey), plus all derivation steps. To support constructing
144
144
these, we permit providing this key origin information inside the
@@ -150,6 +150,10 @@ fingerprint plus optional derivation steps (hardened and unhardened)
150
150
surrounded by brackets, identifying the master and derivation path the key or xpub
151
151
that follows was derived with.
152
152
153
+
Note that the fingerprint of the parent only serves as a fast way to detect
154
+
parent and child nodes in software, and software must be willing to deal with
155
+
collisions.
156
+
153
157
### Including private keys
154
158
155
159
Often it is useful to communicate a description of scripts along with the
0 commit comments