Skip to content

Commit 37932f9

Browse files
Merge pull request #944 from lightninglabs/docs-lnd
Update lnd documentation
2 parents 4f0ee5d + d576c82 commit 37932f9

File tree

3 files changed

+205
-214
lines changed

3 files changed

+205
-214
lines changed

docs/lnd/INSTALL.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,23 @@ following build dependencies are required:
9393

9494
### Installing Go
9595

96-
`lnd` is written in Go, with a minimum version of `1.24.8` (or, in case this
96+
`lnd` is written in Go, with a minimum version of `1.24.9` (or, in case this
9797
document gets out of date, whatever the Go version in the main `go.mod` file
9898
requires). To install, run one of the following commands for your OS:
9999

100100
<details>
101101
<summary>Linux (x86-64)</summary>
102102

103103
```
104-
wget https://dl.google.com/go/go1.24.8.linux-amd64.tar.gz
105-
echo "6842c516ca66c89d648a7f1dbe28e28c47b61b59f8f06633eb2ceb1188e9251d go1.24.8.linux-amd64.tar.gz" | sha256sum --check
104+
wget https://dl.google.com/go/go1.24.9.linux-amd64.tar.gz
105+
echo "5b7899591c2dd6e9da1809fde4a2fad842c45d3f6b9deb235ba82216e31e34a6 go1.24.9.linux-amd64.tar.gz" | sha256sum --check
106106
```
107107

108-
The command above should output `go1.24.8.linux-amd64.tar.gz: OK`. If it
108+
The command above should output `go1.24.9.linux-amd64.tar.gz: OK`. If it
109109
doesn't, then the target REPO HAS BEEN MODIFIED, and you shouldn't install
110110
this version of Go. If it matches, then proceed to install Go:
111111
```
112-
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.24.8.linux-amd64.tar.gz
112+
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.24.9.linux-amd64.tar.gz
113113
export PATH=$PATH:/usr/local/go/bin
114114
```
115115
</details>
@@ -118,15 +118,15 @@ requires). To install, run one of the following commands for your OS:
118118
<summary>Linux (ARMv6)</summary>
119119

120120
```
121-
wget https://dl.google.com/go/go1.24.8.linux-armv6l.tar.gz
122-
echo "3ed8537300ab22449885a43d2931336a571df72c5433d2db4377fe7e2d5e83db go1.24.8.linux-armv6l.tar.gz" | sha256sum --check
121+
wget https://dl.google.com/go/go1.24.9.linux-armv6l.tar.gz
122+
echo "39dafc8e7e5e455995f87e1ffc6b0892302ea519c1f0e59c9e2e0fda41b8aa56 go1.24.9.linux-armv6l.tar.gz" | sha256sum --check
123123
```
124124

125-
The command above should output `go1.24.8.linux-armv6l.tar.gz: OK`. If it
125+
The command above should output `go1.24.9.linux-armv6l.tar.gz: OK`. If it
126126
isn't, then the target REPO HAS BEEN MODIFIED, and you shouldn't install
127127
this version of Go. If it matches, then proceed to install Go:
128128
```
129-
sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.8.linux-armv6l.tar.gz
129+
sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.9.linux-armv6l.tar.gz
130130
export PATH=$PATH:/usr/local/go/bin
131131
```
132132

docs/lnd/key_import.md

Lines changed: 82 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
# Key Import
2-
3-
## Overview
4-
5-
This document serves as an introductory point for users interested in reducing\
6-
their hot-wallet risks, allowing them to maintain on-chain funds outside of`lnd` but still be able to manage them within `lnd`. As of `v0.13.0-beta`, `lnd`\
7-
is able to import BIP-0049 and BIP-0084 extended public keys either at the\
8-
account path (`m/purpose'/coin_type'/account'`) or at the address index path\
9-
(`m/purpose'/coin_type'/account'/change/address_index`) as watch-only through\
1+
# Overview
2+
3+
This document serves as an introductory point for users interested in reducing
4+
their hot-wallet risks, allowing them to maintain on-chain funds outside of
5+
`lnd` but still be able to manage them within `lnd`. As of `v0.13.0-beta`, `lnd`
6+
is able to import BIP-0049 and BIP-0084 extended public keys either at the
7+
account path (`m/purpose'/coin_type'/account'`) or at the address index path
8+
(`m/purpose'/coin_type'/account'/change/address_index`) as watch-only through
109
the `WalletKit` APIs.
1110

12-
Note that in order to follow the rest of this document and/or use the`WalletKit` APIs, users will need to obtain an `lnd` build compiled with the`walletrpc` tag. Our release builds already include this tag by default, so this\
11+
Note that in order to follow the rest of this document and/or use the
12+
`WalletKit` APIs, users will need to obtain an `lnd` build compiled with the
13+
`walletrpc` tag. Our release builds already include this tag by default, so this
1314
would only be necessary when compiling from source.
1415

15-
## `lnd`'s Default Wallet Accounts
16+
# `lnd`'s Default Wallet Accounts
1617

1718
Upon initializing `lnd`, a wallet is created with four default accounts:
1819

19-
* A custom BIP-0049 account (more on this later) to generate NP2WKH external\
20+
* A custom BIP-0049 account (more on this later) to generate NP2WKH external
2021
addresses.
2122
* A BIP-0084 account to generate P2WKH external and change addresses.
22-
* A catch-all BIP-0049 account where all imported BIP-0049 address keys (NP2WKH\
23+
* A catch-all BIP-0049 account where all imported BIP-0049 address keys (NP2WKH
2324
addresses) exist within.
24-
* A catch-all BIP-0084 account where all imported BIP-0049 address keys (P2WKH\
25+
* A catch-all BIP-0084 account where all imported BIP-0049 address keys (P2WKH
2526
addresses) exist within.
2627

27-
Prior to `v0.13.0-beta`, these accounts were abstracted away from users. As part\
28-
of the key import feature, they are now exposed through the new `WalletKit` RPCs\
29-
(`ListAccounts`, `ImportAccount`, `ImportPublicKey`) and the `lncli wallet accounts` command.
28+
Prior to `v0.13.0-beta`, these accounts were abstracted away from users. As part
29+
of the key import feature, they are now exposed through the new `WalletKit` RPCs
30+
(`ListAccounts`, `ImportAccount`, `ImportPublicKey`) and the `lncli wallet
31+
accounts` command.
3032

3133
```shell
3234
$ lncli wallet accounts
@@ -45,10 +47,11 @@ OPTIONS:
4547
--help, -h show help
4648
```
4749

48-
### Account Details
50+
## Account Details
4951

50-
Before interacting with the new set of APIs, users will want to become familiar\
51-
with how wallet accounts are represented within `lnd`. The`WalletKit.ListAccounts` RPC or `lncli wallet accounts list` command can be used\
52+
Before interacting with the new set of APIs, users will want to become familiar
53+
with how wallet accounts are represented within `lnd`. The
54+
`WalletKit.ListAccounts` RPC or `lncli wallet accounts list` command can be used
5255
to retrieve the details of accounts.
5356

5457
```shell
@@ -79,77 +82,78 @@ $ lncli wallet accounts list
7982
}
8083
```
8184

82-
There's a lot to unpack in the response above, so let's cover each account field\
83-
in detail. As mentioned above, four default accounts should exist, though only\
84-
two are shown in the output. The catch-all imported accounts are hidden by\
85+
There's a lot to unpack in the response above, so let's cover each account field
86+
in detail. As mentioned above, four default accounts should exist, though only
87+
two are shown in the output. The catch-all imported accounts are hidden by
8588
default until a key has been imported into them.
8689

87-
* `name`: Each account has a name it can be identified by. `lnd`'s default\
88-
spendable accounts have the name "default". The default catch-all imported\
90+
* `name`: Each account has a name it can be identified by. `lnd`'s default
91+
spendable accounts have the name "default". The default catch-all imported
8992
accounts have the name "imported".
90-
* `extended_public_key`: The BIP-0044 extended public key for the account. Any\
91-
addresses generated for the account are derived from this key. Each key has a\
92-
version prefix that identifies the chain and derivation scheme being used. At\
93+
* `extended_public_key`: The BIP-0044 extended public key for the account. Any
94+
addresses generated for the account are derived from this key. Each key has a
95+
version prefix that identifies the chain and derivation scheme being used. At
9396
the time of writing, `lnd` supports the following versions:
94-
* `xpub/tpub`: The commonly used version prefix originally intended for\
95-
BIP-0032 mainnet/testnet extended keys. Since `lnd` does not support\
96-
BIP-0032 extended keys, this version serves as a catch-all for the other\
97+
* `xpub/tpub`: The commonly used version prefix originally intended for
98+
BIP-0032 mainnet/testnet extended keys. Since `lnd` does not support
99+
BIP-0032 extended keys, this version serves as a catch-all for the other
97100
versions.
98101
* `ypub/upub`: The version prefix for BIP-0049 mainnet/testnet extended keys.
99102
* `zpub/vpub`: The version prefix for BIP-0084 mainnet/testnet extended keys.
100-
* `address_type`: The type of addresses the account can derive. There are three\
103+
* `address_type`: The type of addresses the account can derive. There are three
101104
supported address types:
102-
* `WITNESS_PUBKEY_HASH`: The standard derivation scheme for BIP-0084 with\
105+
* `WITNESS_PUBKEY_HASH`: The standard derivation scheme for BIP-0084 with
103106
P2WKH for external and change addresses.
104-
* `NESTED_WITNESS_PUBKEY_HASH`: The standard derivation scheme for BIP-0049\
107+
* `NESTED_WITNESS_PUBKEY_HASH`: The standard derivation scheme for BIP-0049
105108
with P2WKH for external and change addresses.
106-
* `HYBRID_NESTED_WITNESS_PUBKEY_HASH` A custom derivation scheme for BIP-0049\
107-
used by `lnd` where NP2WKH is used for external addresses and P2WKH for\
109+
* `HYBRID_NESTED_WITNESS_PUBKEY_HASH` A custom derivation scheme for BIP-0049
110+
used by `lnd` where NP2WKH is used for external addresses and P2WKH for
108111
change addresses.
109-
* `master_key_fingerprint`: The 4 byte fingerprint of the master key\
110-
corresponding to the account. This is usually required by hardware\
112+
* `master_key_fingerprint`: The 4 byte fingerprint of the master key
113+
corresponding to the account. This is usually required by hardware
111114
wallet/external signers to identify the proper signing key.
112-
* `derivation_path`: The BIP-0044 derivation path used on the master key to\
115+
* `derivation_path`: The BIP-0044 derivation path used on the master key to
113116
obtain the account key.
114117
* `external_key_count`: The number of external addresses generated.
115118
* `internal_key_count`: The number of change addresses generated.
116-
* `watch_only`: Whether the wallet has private key information for the account.`lnd`'s default wallet accounts always have private key information, so this\
119+
* `watch_only`: Whether the wallet has private key information for the account.
120+
`lnd`'s default wallet accounts always have private key information, so this
117121
value is `false`.
118122

119-
## Key Import
123+
# Key Import
120124

121-
An existing limitation to the key import APIs is that events (deposits/spends)\
122-
for imported keys, including those derived from an imported account, will only\
123-
be detected by lnd if they happen after the import. Rescans to detect past\
125+
An existing limitation to the key import APIs is that events (deposits/spends)
126+
for imported keys, including those derived from an imported account, will only
127+
be detected by lnd if they happen after the import. Rescans to detect past
124128
events are currently not supported, but will come at a later time.
125129

126-
### Account Key Import
130+
## Account Key Import
127131

128-
The `WalletKit.ImportAccount` RPC and `lncli wallet accounts import` command can\
129-
be used to import an account. At the time of writing, importing an account has\
132+
The `WalletKit.ImportAccount` RPC and `lncli wallet accounts import` command can
133+
be used to import an account. At the time of writing, importing an account has
130134
the following request parameters:
131135

132136
* `name` (required): A name to identify the imported account with.
133-
* `extended_public_key` (required): A public key that corresponds to a wallet account\
134-
represented as an extended key. It must conform to a derivation path of the\
137+
* `extended_public_key` (required): A public key that corresponds to a wallet account
138+
represented as an extended key. It must conform to a derivation path of the
135139
form `m/purpose'/coin_type'/account'`.
136-
* `master_key_fingerprint` (optional): The fingerprint of the root key (also\
137-
known as the key with derivation path m/) from which the account public key\
138-
was derived from. This may be required by some hardware wallets for proper\
140+
* `master_key_fingerprint` (optional): The fingerprint of the root key (also
141+
known as the key with derivation path m/) from which the account public key
142+
was derived from. This may be required by some hardware wallets for proper
139143
identification and signing.
140-
* `address_type` (optional): An address type is only required when the extended\
141-
account public key has a legacy version (xpub, tpub, etc.), such that the\
144+
* `address_type` (optional): An address type is only required when the extended
145+
account public key has a legacy version (xpub, tpub, etc.), such that the
142146
wallet cannot detect what address scheme it belongs to.
143-
* `dry_run` (optional): Whether a dry run should be attempted when importing the\
144-
account. This serves as a way to confirm whether the account is being imported\
145-
correctly by returning the first N addresses for the external and internal\
146-
branches of the account. If these addresses match as expected, then it should\
147+
* `dry_run` (optional): Whether a dry run should be attempted when importing the
148+
account. This serves as a way to confirm whether the account is being imported
149+
correctly by returning the first N addresses for the external and internal
150+
branches of the account. If these addresses match as expected, then it should
147151
be safe to import the account as is.
148152

149-
For the sake of simplicity, we'll present an example with two `lnd` nodes Alice\
150-
and Bob, where Alice acts as a signer _only_, and Bob manages Alice's on-chain\
151-
BIP-0084 account by crafting transactions and watching/spending addresses. Since\
152-
Alice will only act as a signer, we'll want to import her BIP-0084 account into\
153+
For the sake of simplicity, we'll present an example with two `lnd` nodes Alice
154+
and Bob, where Alice acts as a signer _only_, and Bob manages Alice's on-chain
155+
BIP-0084 account by crafting transactions and watching/spending addresses. Since
156+
Alice will only act as a signer, we'll want to import her BIP-0084 account into
153157
Bob's node, which will require knowledge of Alice's extended public key.
154158

155159
Alice's BIP-0084 extended public key can be obtained as follows.
@@ -178,10 +182,10 @@ Bob can then import the account with the following command:
178182
$ lncli-bob wallet accounts import vpub5Z9beF6NYCrHeDmKC38tM3xXMDFFSARa9sdHRPChEMGqtxiELfZB8hm6FwBpBvfPpX2HGG8edYVV9Wupe43PEJJhhfnz1egtQNNaDXyYExn alice
179183
```
180184

181-
Before Bob imports the account, they may want to confirm the account is being\
182-
imported using the correct derivation scheme. This can be done with the dry run\
183-
request parameter. When a dry run is done, the response will include the usual\
184-
account details, as well as the first 5 external and change addresses, which can\
185+
Before Bob imports the account, they may want to confirm the account is being
186+
imported using the correct derivation scheme. This can be done with the dry run
187+
request parameter. When a dry run is done, the response will include the usual
188+
account details, as well as the first 5 external and change addresses, which can
185189
be used to confirm they match with what the account owner expects.
186190

187191
```shell
@@ -214,7 +218,7 @@ $ lncli-bob wallet accounts import vpub5Z9beF6NYCrHeDmKC38tM3xXMDFFSARa9sdHRPChE
214218
}
215219
```
216220

217-
Once Bob has confirmed the correct account derivation scheme is being used, the\
221+
Once Bob has confirmed the correct account derivation scheme is being used, the
218222
account can be imported without the dry run parameter.
219223

220224
```shell
@@ -233,14 +237,14 @@ $ lncli-bob wallet accounts import vpub5Z9beF6NYCrHeDmKC38tM3xXMDFFSARa9sdHRPChE
233237
}
234238
```
235239

236-
#### Generating Addresses from an Imported Account
240+
### Generating Addresses from an Imported Account
237241

238-
External addresses from an imported account can be generated through the\
239-
existing `Lightning.NewAddress` RPC and `lncli newaddress` command, as they now\
240-
take an additional optional parameter to specify which account the address\
242+
External addresses from an imported account can be generated through the
243+
existing `Lightning.NewAddress` RPC and `lncli newaddress` command, as they now
244+
take an additional optional parameter to specify which account the address
241245
should be derived from.
242246

243-
Following the example above, Bob is able to generate an external address for an\
247+
Following the example above, Bob is able to generate an external address for an
244248
incoming deposit as follows:
245249

246250
```shell
@@ -250,15 +254,15 @@ $ lncli-bob newaddress p2wkh --account=alice
250254
}
251255
```
252256

253-
Change addresses cannot be generated on demand, they are generated automatically\
257+
Change addresses cannot be generated on demand, they are generated automatically
254258
when a transaction is crafted that requires a change output.
255259

256-
#### Crafting Transactions through PSBTs from an Imported Account
260+
### Crafting Transactions through PSBTs from an Imported Account
257261

258-
Assuming a deposit of 1 tBTC was made to the address above\
259-
(`bcrt1q8zdjz2q92eh7jw9ah3upf2u9553226gq79el5l`), Bob should be able to craft a\
260-
transaction spending their new UTXO. Since Bob is unable to sign the transaction\
261-
themselves, they'll use PSBTs to craft the transaction, and provide it to Alice\
262+
Assuming a deposit of 1 tBTC was made to the address above
263+
(`bcrt1q8zdjz2q92eh7jw9ah3upf2u9553226gq79el5l`), Bob should be able to craft a
264+
transaction spending their new UTXO. Since Bob is unable to sign the transaction
265+
themselves, they'll use PSBTs to craft the transaction, and provide it to Alice
262266
to sign.
263267

264268
```shell

0 commit comments

Comments
 (0)