lightningnetwork / lnd

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

admin.macaroon is not created when running lnd #1190

Closed ripper234 closed 6 years ago

ripper234 commented 6 years ago

Background

I successfully completed stage 1 of the tutorial using --no-macaroons. Now I'm trying to learn how to use macaroons.

The tutorial does not explain how to create the admin.macaroon file. When I run lnd, it waits for the either lncli create or lncli unlock. No admin.macaroon file can be found anywhere on disk at this point.

These commands (lncli) however seem to require the existence of an admin.macaroon file.

>lncli --rpcserver=localhost:10001 --macaroonpath=C:\work\lnd\alice\data\admin.macroon getinfo
[lncli] open C:\work\lnd\alice\data\admin.macroon: The system cannot find the file specified.

Tried to touch it and then I got

[lncli] empty macaroon data

So, how do I create an initial macaroon file?

Your environment

dabura667 commented 6 years ago

if lnd is running with -no-macaroons, you don’t need to specify the macaroon

ripper234 commented 6 years ago

It is no longer running with -no-macaroons, I just said that everything worked for me before without macaroons, I'm trying to get it to work with them now.

dabura667 commented 6 years ago

If you run lnd in macaroon mode it automatically generates the macaroon in the default location.

Move the macaroon file to your folder you are specifying

ripper234 commented 6 years ago

Is that the macaroons.db file? Because the tutorial speaks of admin.macaroon, but the file I see on disk is macaroons.db.

ripper234 commented 6 years ago

When I try to use macaroons.db as admin.macaroon I get

[lncli] cannot determine data format of binary-encoded macaroon

So admin.macaroon must be something else. But I'm not seeing that on disk anywhere (looked in C:\Users\User\AppData\Local\Lnd, and in my local folders).

ripper234 commented 6 years ago

It seems that just running lnd with no parameters creates the macaroons.db file, but contrary to the documentation it does not create an admin.macaroon file.

guggero commented 6 years ago

The admin.macaroon is only created after you run lncli unlock or lncli create. So you should run either of these commands first. The macaroons.db is where the root key for the macaroons is stored, so it's in a different format and cannot be used for the --macaroonpath parameter.

ripper234 commented 6 years ago

But doesn't lncli unlock require --macaroonpath? From your answer I guess not. Ok, I will try this flow again and reopen if I run into issues.

autemox commented 6 years ago

The admin.macaroon is only created after you run lncli unlock or lncli create. So you should run either of these commands first. The macaroons.db is where the root key for the macaroons is stored, so it's in a different format and cannot be used for the --macaroonpath parameter.

When I do "lncli --rpcserver=localhost:10001 --macaroonpath=data/admin.macaroon create" no admin.macaroon file is created. Like the OP I have been able to do the tutorial with --no-macaroons on but when I try to complete the tutorial with macaroons, I have serious problem with no admin.macaroon file existing.

ereztdev commented 6 years ago

echoing this issue, I followed the same path of creating the macaroon, my network is testnet stipulated in lnd.conf as:

[Bitcoin]
bitcoin.testnet=1
bitcoin.active=1
bitcoin.node=btcd

created the macaroon with: lncli --rpcserver=localhost:10001 --macaroonpath=data/admin.macaroon create for user under $GOPATH/dev/user/ After entering + confirming pwd, refusing passphrase + enter for surpassing cipher seed passphrase fresh cipher seed generated. checking under $GOPATH/dev/user/data/ no macaroon created.

I have to say that on my first run going through simnet with the alice/bob/charlie demo it did not work until I passed the network param stating simnet, now i'm trying to do the same, changed the lnd.conf to testnet and now macaroons are not created.

cfromknecht commented 6 years ago

@autemox @ereztdev the network parameter needs to be passed like lncli --network=testnet .... The macaroons are no longer stored in the top level data directory, they are stored in /data/chain/bitcoin/<network> iirc. Passing the network flag instructs lncli to grab the proper one

@autemox you shouldn’t have to pass a macaroon to create, that would create a cyclic dependency requiring the macaroon be generated before lnd has ever started

ereztdev commented 6 years ago

Ok @cfromknecht, your right, yet it would be wise to return a path created since the call is: lncli --network=testnet --rpcserver=localhost:10001 --macaroonpath=data/admin.macaroon create Which stipulates saving to data folder.

cfromknecht commented 6 years ago

@ereztdev macaroonpath is always passed as an argument for where to read a macaroon. It is never used as the location to save one. Again, no macaroon path argument is required for create

BrianSipple commented 5 years ago

I think the confusion here stems from two things:

  1. The tutorial snippet for lncli create uses --macaroonpath, even though it’s not needed.
  2. The path is incorrect — assuming we want it to match the file that’s automatically generated after initially running lncli create.

2. causes errors when trying to proceed from the tutorial after 1.

I submitted a PR for the fix.

guilhermehas commented 5 years ago

Try to do find . -name "admin.macaroon" It saved the file in this location data/chain/bitcoin/simnet/admin.macaroon You can copy and paste to the right folder cp data/chain/bitcoin/simnet/admin.macaroon data

A-qiu161203 commented 4 years ago

sir, I met the same problem as you. Have you solved this problem yet? Could you please help me? Thank you very much!

frazras commented 2 years ago

Found mine at ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon