Lnd: [lncli] rpc error: code = Unknown desc = cannot get macaroon: root key with id 0 doesn't exist

Created on 23 Aug 2017  路  8Comments  路  Source: lightningnetwork/lnd

Hi,

I've been getting this error when I am attempting to generate a new address using either p2pkh, p2wkh or np2wkh:

[user@pc lnd]$ lncli newaddress p2wkh
[lncli] rpc error: code = Unknown desc = cannot get macaroon: root key with id 0 doesn't exist

Lncli version- 0.2.1

My LTN chainstate is currently synched to the latest block header on the BTCN testnet.

Kindly help me out on this.

Thanks

Most helpful comment

For future reference: this is a symptom that the data directory was deleted (including the macaroons database) and the macaroons in the root directory weren't. The admin.macaroon and readonly.macaroon files are for clients to use, but they encode macaroons that are usable only with the macaroon database for that instance; if the macaroon database is deleted, those files become invalid and must be deleted and regenerated.

All 8 comments

is this only an issue with the newaddress command?

One workaround is to just start lnd with the extra argument --no-macaroons

@halseth Just checked it happens even with other commands.

I've also tried the following and ended up with the following error:

[user@pc lnd]$ lncli --no-macaroons newaddress np2wkh
[lncli] rpc error: code = Unknown desc = expected 1 macaroon, got 0

Try passing it as an argument when you start your lnd node:

[user@pc lnd]$ lnd --no-macaroons

then issue the lncli command as before:

[user@pc lnd]$ lncli newaddress p2wkh

@halseth Thank you, trying it out. Also have another question. What's the safer way to stop lnd? At the moment I ran lnd --no-macaroons and I get this:
Started rescan from block 00000000145850f562e423304bab37b00b48ac8a0ee9b3bd944d14ee68f907e5 (height 62385) for 1 address

You can do lncli stop or just press ctrl-c in the lnd terminal :)

@helseth Thank you very much for your time and support! The address got succesfully generated. You're amazing!

For future reference: this is a symptom that the data directory was deleted (including the macaroons database) and the macaroons in the root directory weren't. The admin.macaroon and readonly.macaroon files are for clients to use, but they encode macaroons that are usable only with the macaroon database for that instance; if the macaroon database is deleted, those files become invalid and must be deleted and regenerated.

@aakselrod You're right, I had deleted the database files but forgot to delete admin.macaroon and readonly.macaroon. Thanks for pointing that one out!

Was this page helpful?
0 / 5 - 0 ratings