lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.73k stars 2.1k forks source link

get master public key? #4050

Closed anonproject closed 4 years ago

anonproject commented 4 years ago

I am planning to play around with autopilot on mainnet. I was able to setup lnd with bitcoind full node via tor. I was able to generate a new address via lncli newaddress p2wkh. Now I just want to check if I can generate the address I received via some kind of mpk.

While it is true that I've got some long seed when I created a wallet, it is unclear how to generate the addresses that are used in lnd. For example what the derivation path is?

Is there any easy way to generate the addresses from the 24-word seed I got?

guggero commented 4 years ago

Currently lnd doesn't have any functionality to export key material. I built two tools you could use. One web based (https://guggero.github.io/cryptography-toolkit/#!/aezeed) and one command line based (https://github.com/guggero/chantools, use the showrootkey command). Both will export the master private key, but you should be able to convert it to an xpub. The derivation path for p2wkh is a default BIP84 path, for example: m/84'/0'/0'/0/0 For np2wkh it's a default BIP49 path, for example: m/49'/0'/0'/0/0.

barisser commented 3 years ago

"Currently lnd doesn't have any functionality to export key material."

I think this is a really critical feature.

guggero commented 3 years ago

With lnd v0.13.0-beta (currently in RC3), you can now export the extended public key of each account. See lncli wallet accounts list.

ArmanTheParman commented 2 years ago

Would be good to be able to export the extended private keys (zprv, yprv, xprv) to import into Electrum. This way you can practice good coin control to maximise privacy when spending from the lightning wallet. Currently, spending from LND does not allow fine control of which UTXOs to include in a transaction as far as I can tell. Electrum fixes that, and it's easy enough to use, just need access to the extended private keys that will generate both internal and external chains.

guggero commented 2 years ago

As mentioned, you can use the above tool to convert your seed into an xprv. But you shouldn't really use your lnd's seed outside of lnd's wallet, as that might mess up the internal wallet state if you spend stuff externally. And there is full coin control when using the PSBT feature. See lncli listunspent, lncli wallet psbt fund and lncli wallet psbt finalize.

ArmanTheParman commented 2 years ago

Thank you! Unfortunately, I have already made some spends, but advice noted for next time. It was just a way to not have to set up an additional hot wallet. Will look into the PSBT feature, thanks. Parman

On Thu, Oct 27, 2022 at 6:48 PM Oliver Gugger @.***> wrote:

As mentioned, you can use the above tool to convert your seed into an xprv. But you shouldn't really use your lnd's seed outside of lnd's wallet, as that might mess up the internal wallet state if you spend stuff externally. And there is full coin control when using the PSBT feature. See lncli listunspent, lncli wallet psbt fund and lncli wallet psbt finalize.

— Reply to this email directly, view it on GitHub https://github.com/lightningnetwork/lnd/issues/4050#issuecomment-1293127410, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASQCCX75A2TUEMY3JFZTSADWFIXTHANCNFSM4LCBAQ4Q . You are receiving this because you commented.Message ID: @.***>