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: docs/03_4_Understanding_the_Descriptor_Wallet.md
+35-29Lines changed: 35 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,15 +21,24 @@ private key, which includes not just the private key but also a "chain
21
21
code" that can be used to create descendents of that key. The key and
22
22
chain code can be used to deterministically generate chains of keys
23
23
(and therefore addresses) for a variety of purposes. A Bitcoin HD
24
-
wallet will typically have individual chains of keys (and addresses)
25
-
for a variety of different address types. But, they can all be
26
-
restored from that seed (or from that master extended private key)
27
-
because of their determinism: the addresses are always created in the
28
-
same way provided that you have the same starting points (which
29
-
include your master extended private key and a specific index
30
-
[0,1,...,n] for a specific type of address).
31
-
32
-
> 📖 ***What is a BIP?*** A BIP is a Bitcoin Improvement Proposal. It's an in-depth suggestion for a change to the Bitcoin Core code. Often, when a BIP has been sufficiently discussed and updated, it will become an actual part of the Bitcoin Core code. BIP-32 is one of many examples.
24
+
wallet will typically have individual accounts, which are chains of
25
+
keys (and addresses) for a variety of different address types. But,
26
+
they can all be restored from that seed (or from that master extended
27
+
private key) because of their determinism: the addresses are always
28
+
created in the same way provided that you have the same starting
29
+
points (which include your master extended private key and a specific
30
+
index [0,1,...,n] for a specific type of address).
31
+
32
+
> 📖 ***What is a BIP?*** A BIP is a Bitcoin Improvement
33
+
Proposal. It's an in-depth suggestion for a change to the Bitcoin Core
34
+
code. Often, when a BIP has been sufficiently discussed and updated,
35
+
it will become an actual part of the Bitcoin Core code. BIP-32 is one
36
+
of many examples.
37
+
38
+
The higher levels of secrets, the seeds and the master keys, are
39
+
largely hidden from you in Bitcoin Core, but we'll talk about how to
40
+
import them from the larger ecosystem in [chapter
41
+
10](10_0_Working_with_Secrets.md).
33
42
34
43
## Understand Descriptor Wallets
35
44
@@ -61,30 +70,27 @@ didn't have that, a new wallet would have to test a master extended
61
70
public key against _every possible type of address_ and that was going
62
71
to be very inefficient and time-consuming and still introduced the
63
72
likelihood of losing funds.
64
-
65
-
> 📖 **What is a seed phase?** A collection of mnemonic words can
66
-
define a seed. That seed is then used to generate an extended private
67
-
key. Seed phrases are not currently used by Bitcoin Core, but they are
68
-
in wide use in the larger Bitcoin ecosystem. Future chapters will talk
69
-
about how to use third-party tools to transform seed phrases into keys
70
-
that can be imported into `bitcoin-cli`.
71
73
72
74
> 📖 ***What is xprv?*** Xprv stands for extended private key. This is
73
75
the combination of a private key and a chain code. It's a private key
74
76
that a whole sequence of children private keys can be derived from.
75
77
76
-
> 📖 ***What is xpub?*** Xpub stands for extended public key. This is the combination of a public key and a chain code. It's a public key that a whole sequence of children public keys can be derived from.
78
+
> 📖 ***What is xpub?*** Xpub stands for extended public key. This is
79
+
the combination of a public key and a chain code. It's a public key
80
+
that a whole sequence of children public keys can be derived from.
77
81
78
82
Enter, at last, the descriptor wallet. A descriptor wallet collects
79
83
together "output descriptors" (sometimes called "wallet descriptors"),
80
84
which each either define one address or, with a special "ranged
81
85
descriptor", a whole array of addresses, each at a separate
82
86
index. They do so through the specification of a format that includes:
83
87
one or more nested functions (which define how to unlock the Bitcoin
84
-
at the address), a derivation path (which defines the purpose of an
85
-
address, which mostly links it to a specific standard), either the
86
-
master extended public key or the master extended private key, and a
87
-
checksum to make sure that nothing has been corrupted.
88
+
at the address), a derivation path (which not only derives a specific
89
+
account or address key from the master key but also provides
90
+
information by defining the purpose of an address, which mostly links
91
+
it to a specific standard), either the account public key or the
92
+
account private key, and a checksum to make sure that nothing has been
93
+
corrupted.
88
94
89
95
> 📖 ***What is a Derivation Path?*** When you have hierarchical keys,
90
96
you need to be able to define individual keys as descendents of the
@@ -103,7 +109,7 @@ equivalent.
103
109
104
110
The derivation path allows you to calculate the right key from the
105
111
master extended key, but it's the introduction of functions into
106
-
descriptors that makes them particularly powerful, because they allows
112
+
descriptors that makes them particularly powerful, because they allow
107
113
descriptors to serve a number of different types of past, present, and
108
114
future addresses (which we'll meet in
109
115
[§4.1](04_1_Understanding_the_Address.md)).
@@ -232,13 +238,13 @@ can deterministically be created on the fly.
232
238
233
239
* There are four types of addresses, which we'll meet in the next chapter (`pkh`, `sh`, `tr`, and `wpkh`).
234
240
* Each type of address supports external addresses (for receiving funds from other wallets) and internal addresses (for sending change back to this wallet), as defined by `internal`.
235
-
* Each type of address has its own key (e.g., `tpubDCsocyjrtJLXKJ3atFwKf6FiPheuVNV27B1swsGiNvk4cuPhVTsCDvusSNcH8thnS68FPFotgHqo9FHNGrvhtx6ZqdbWBQTWrCgK9xous17`).
241
+
* Each type of address has its own account key (e.g., `tpubDCsocyjrtJLXKJ3atFwKf6FiPheuVNV27B1swsGiNvk4cuPhVTsCDvusSNcH8thnS68FPFotgHqo9FHNGrvhtx6ZqdbWBQTWrCgK9xous17`).
236
242
* Each type of address supports a range of addresses, initially running 0 to 999.
237
243
238
-
In other words, even though you have 8 descriptors, that's replacing
239
-
thousands of addresses. Thatt's a huge boon for backups (when you
240
-
want to protect your funds) and for moving control of your funds from
241
-
one wallet-app to another.
244
+
In other words, even though you have eight descriptors, that's
245
+
replacing thousands of addresses. That's a huge boon for backups
246
+
(when you want to protect your funds) and for moving control of your
247
+
funds from one wallet-app to another.
242
248
243
249
With that understood, we can look more closely at one of the descriptors:
244
250
@@ -269,7 +275,7 @@ As for the descriptor itself, let's break that down further:
269
275
***Function: `wpkh`.** The function that is used to create an address from that key. In this cases it's `wpkh`. That stands for "Witness Public Key Hash," which is one of the methods used to unlock a Bech32 address, which we'll meet in the next chapter.
270
276
***Fingerprint: `e18dae20`.** This is a fingerprint of the master extended public key. It tells you which secret was used to generate this address. The fingerprint is *not* necessary to generate the keys and addresses for a derivation, it's just helpful if you need to go back and find the secret that generated your extended keys.
271
277
***Derivation Path: `/84h/1h/0h`.** This describes what part of an HD wallet is being exported. This is the 0th child key of the 1st child of the 84th child in the HD tree. The various levels in the derivation path have very specific meanings as defined in [BIP-44](https://en.bitcoin.it/wiki/BIP_0044): `/purpose/coin_type/account/`. The purpose of this derivation path is "84", which means that it follows [BIP-84](https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki), which describes WPKH derivation. The coin type is "1", which means that it's a testnet or signet coin. (A mainnet coin could would be "0".) The account is "0", as it's the only account in our wallet.
272
-
***Key: `tpubDC4ujMbsd9REzpGk3gnTjkrfJFw1NnvCpx6QBbLj3CHBzcLmVzssTVP8meRAM1WW4pZnK6SCCPGyzi9eMfzSXoeFMNprqtgxG71VRXTmetu`.** This is the signet or testnet extended master public key that was used to generate this derived key. (A private key could be here instead. A public key would demonstrate how to watch this series of addresses, while a private key would show to control them.)
278
+
***Key: `tpubDC4ujMbsd9REzpGk3gnTjkrfJFw1NnvCpx6QBbLj3CHBzcLmVzssTVP8meRAM1WW4pZnK6SCCPGyzi9eMfzSXoeFMNprqtgxG71VRXTmetu`.** This is the signet or testnet account public key for this address type. (A private key could be here instead. A public key would demonstrate how to watch this series of addresses, while a private key would show to control them.)
273
279
***Range: `/0/*`.** These are actually the final two parts of the derivation path, which are defined by BIP-44 as `change/address_index`. The "0" says it's an external address. (An internal or change address would be "1".) The `*` says it's a ranged address, which means that it's defining a whole set of WPKH addresses that could be created.
274
280
***`#3658f8sn"`.** This is a checksum showing the descriptor isn't corrupted.
275
281
@@ -347,4 +353,4 @@ creating.
347
353
348
354
## What's Next?
349
355
350
-
MOove on to "addresses" with [Chapter Three: Preparing Your Bitcoin Addresses](04_0_Preparing_Your_Bitcoin_Addresses.md).
356
+
Move on to "addresses" with [Chapter Three: Preparing Your Bitcoin Addresses](04_0_Preparing_Your_Bitcoin_Addresses.md).
0 commit comments