Skip to content

Commit 77f4a91

Browse files
edited for new chapter 10 work
1 parent 2ee402f commit 77f4a91

4 files changed

Lines changed: 65 additions & 29 deletions

docs/03_4_Understanding_the_Descriptor_Wallet.md

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,24 @@ private key, which includes not just the private key but also a "chain
2121
code" that can be used to create descendents of that key. The key and
2222
chain code can be used to deterministically generate chains of keys
2323
(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).
3342

3443
## Understand Descriptor Wallets
3544

@@ -61,30 +70,27 @@ didn't have that, a new wallet would have to test a master extended
6170
public key against _every possible type of address_ and that was going
6271
to be very inefficient and time-consuming and still introduced the
6372
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`.
7173

7274
> 📖 ***What is xprv?*** Xprv stands for extended private key. This is
7375
the combination of a private key and a chain code. It's a private key
7476
that a whole sequence of children private keys can be derived from.
7577

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.
7781

7882
Enter, at last, the descriptor wallet. A descriptor wallet collects
7983
together "output descriptors" (sometimes called "wallet descriptors"),
8084
which each either define one address or, with a special "ranged
8185
descriptor", a whole array of addresses, each at a separate
8286
index. They do so through the specification of a format that includes:
8387
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.
8894

8995
> 📖 ***What is a Derivation Path?*** When you have hierarchical keys,
9096
you need to be able to define individual keys as descendents of the
@@ -103,7 +109,7 @@ equivalent.
103109

104110
The derivation path allows you to calculate the right key from the
105111
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
107113
descriptors to serve a number of different types of past, present, and
108114
future addresses (which we'll meet in
109115
[§4.1](04_1_Understanding_the_Address.md)).
@@ -232,13 +238,13 @@ can deterministically be created on the fly.
232238

233239
* There are four types of addresses, which we'll meet in the next chapter (`pkh`, `sh`, `tr`, and `wpkh`).
234240
* 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`).
236242
* Each type of address supports a range of addresses, initially running 0 to 999.
237243

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.
242248

243249
With that understood, we can look more closely at one of the descriptors:
244250

@@ -269,7 +275,7 @@ As for the descriptor itself, let's break that down further:
269275
* **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.
270276
* **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.
271277
* **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.)
273279
* **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.
274280
* **`#3658f8sn"`.** This is a checksum showing the descriptor isn't corrupted.
275281

@@ -347,4 +353,4 @@ creating.
347353

348354
## What's Next?
349355

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).

docs/10_0_Working_with_Secrets.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Chapter Ten: Working with Secrets
2+
3+
Bitcoin Core protects you from most of the specifics of how the
4+
addresses in your descriptor wallet are created. In doing so, it also
5+
cuts you off from the wider Bitcoin ecosystem. This chapter bridges
6+
that gap by taking you through the hierarchy of seeds, keys, and
7+
descriptors that result in a Bitcoin address and showing you how to
8+
both import and export the secrets involved.
9+
10+
## Objectives for This Section
11+
12+
After working through this chapter, a developer will be able to:
13+
14+
* Create a Seed Outside of Bitcoin Core
15+
* Import Keys from that Seed into Bitcoin Core
16+
* Export Keys from Bitcoin Core for Storage Elsewhere
17+
18+
Supporting objectives include the ability to:
19+
20+
* Understand the Hierarchy of Bitcoin Secrets
21+
* Understand the Importance of Interoperability
22+
* Understand the Importance of Backups
23+
24+
## Table of Contents
25+
26+
* [Section One: Creating Secrets from the Command Line](10_1_Creating_Secrets_from_the_Command_Line.md)
27+
* [Section Two: Converting Secrets with Keytool](10_2_Converting_Secrets_with_Keytool.md)
28+
* [Section Three: Importing Secrets to Bitcoin Core](10_3_Importing_Secrets_to_Bitcoin_Core.md)
29+
* [Section Four: Exporting Secrets from Bitcoin Core](10_4_Exporting_Secrets_from_Bitcoin_Core.md)
30+
* [Section Five: Storing Secrets with Envelope](10_5_Storing_Secrets_with_Envelope.md)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)