Skip to content

Commit b9961d7

Browse files
Merge pull request #704 from lightninglabs/docs-lnd
Update lnd documentation
2 parents 82393e5 + 10826fa commit b9961d7

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

docs/lnd/macaroons.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,46 @@ Examples:
158158
$ lncli --macaroonpath=/safe/location/admin.macaroon getinfo
159159
```
160160

161+
## Using deterministic/pre-generated macaroons
162+
163+
All macaroons are derived from a secret root key (by default from the root key
164+
with the ID `"0"`). That root key is randomly generated when the macaroon store
165+
is first initialized (when the wallet is created) and is therefore not
166+
deterministic by default.
167+
168+
It can be useful to use a deterministic (or pre-generated) root key, which is
169+
why the `InitWallet` RPC (or the `lncli create` or `lncli createwatchonly`
170+
counterparts) allows a root key to be specified.
171+
172+
Using a pre-generated root key can be useful for scenarios like:
173+
* Testing: If a node is always initialized with the same root key for each test
174+
run, then macaroons generated in one test run can be re-used in another run
175+
and don't need to be re-derived.
176+
* Remote signing setup: When using a remote signing setup where there are two
177+
related `lnd` nodes (e.g. a watch-only and a signer pair), it can be useful
178+
to generate a valid macaroon _before_ any of the nodes are even started up.
179+
180+
**Example**:
181+
182+
The following example shows how a valid macaroon can be generated before even
183+
starting a node:
184+
185+
```shell
186+
# Randomly generate a 32-byte long secret root key and encode it as hex.
187+
ROOT_KEY=$(cat /dev/urandom | head -c32 | xxd -p -c32)
188+
189+
# Derive a read-only macaroon from that root key.
190+
# NOTE: When using the --root_key flag, the `lncli bakemacaroon` command is
191+
# fully offline and does not need to connect to any lnd node.
192+
lncli bakemacaroon --root_key $ROOT_KEY --save_to /tmp/info.macaroon info:read
193+
194+
# Create the lnd node now, using the same root key.
195+
lncli create --mac_root_key $ROOT_KEY
196+
197+
# Use the pre-generated macaroon for a call.
198+
lncli --macaroonpath /tmp/info.macaroon getinfo
199+
```
200+
161201
## Using Macaroons with GRPC clients
162202

163203
When interacting with `lnd` using the GRPC interface, the macaroons are encoded

docs/lnd/release-notes/release-notes-0.19.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646

4747
## lncli Additions
4848

49+
* [A pre-generated macaroon root key can now be specified in `lncli create` and
50+
`lncli createwatchonly`](https://github.com/lightningnetwork/lnd/pull/9172) to
51+
allow for deterministic macaroon generation.
52+
4953
# Improvements
5054
## Functional Updates
5155

0 commit comments

Comments
 (0)