lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.67k stars 2.07k forks source link

Deterministic Macaroon / pub key #5427

Closed bodymindarts closed 2 years ago

bodymindarts commented 3 years ago

Background

For https://github.com/GaloyMoney/galoy we run integration tests with 4 LND instances running at the same time brought up in docker-compose. Our server runtime requires knowledge of the admin.macaroon and identity_pubkey. Currently these are only retrievable once LND has bootstrapped but this adds overhead to running the tests that we would prefer to avoid.

We want to be able to start an LND process in a container with a predetermined admin macaroon and identity_pubkey so that we don't have to wait for LND to start running in order to retrieve the information and continue on with the test setup.

Is there a way to start LND with this data being pre-defined? Or would it be possible to add this as a feature?

Roasbeef commented 3 years ago

Macaroon root keys are generated randomly: https://github.com/lightningnetwork/lnd/blob/master/macaroons/store.go#L353

It would be possible to instead accept the param when running w/ the dev build/debug tag on.

bodymindarts commented 3 years ago

Cool that would solve the Macaroon related part. What about the identity_pubkey (retrieved via lncli getinfo | jq -r .identity_pubkey). Is this also derived from that randomness?

wpaulino commented 3 years ago

The node public key is derived from the seed with path m/1017'/0'/6/0/1, so re-using a seed will always yield the same node public key.

bodymindarts commented 3 years ago

The node public key is derived from the seed with path m/1017'/0'/6/0/1, so re-using a seed will always yield the same node public key.

I'm aware of that. I just cannot see where I can provide the seed deterministically. I cannot find an option in the lnd.conf file.

wpaulino commented 3 years ago

It's part of the initialization/wallet creation process, see https://api.lightning.community/#initwallet.

guggero commented 2 years ago

Will be fixed by https://github.com/lightningnetwork/lnd/pull/6457 (the macaroon part, as mentioned above the identity part is already solved by using the same seed in the wallet initialization process).