lightningnetwork / lnd

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

unable to read admin.macaroon once again #4047

Closed anonproject closed 4 years ago

anonproject commented 4 years ago

Trying to setup lnd for the first time. Can't start it up.

So I downloaded latest beta binaries (v0.9.1-beta) and attempted to run it on Ubuntu 18.04. I created a user satoshi, created its home directory, lnd.conf and tls.cert and tls.key. lnd.conf is configured for bitcoind backend, no-macaroons=true is also specified.

For some reason it I see the following error:

lncli version 0.9.1-beta commit=v0.9.1-beta

Mar 04 19:25:54 VS-48463 lncli[92915]: [lncli] unable to read macaroon path (check the network setting!): open /home/satoshi/.lnd/data/chain/bitcoin/mainnet/admin.macaroon: no such file or directory
Mar 04 19:25:54 VS-48463 systemd[1]: lnd.service: Control process exited, code=exited status=1
Mar 04 19:25:54 VS-48463 systemd[1]: lnd.service: Failed with result 'exit-code'.

root@VS-48463:/home/satoshi/.lnd# ll /home/satoshi/.lnd/data/chain/bitcoin/mainnet/
total 8
drwxr-xr-x 2 satoshi satoshi 4096 Mar  4 17:44 ./
drwxr-xr-x 3 satoshi satoshi 4096 Mar  4 17:44 ../

I am not sure why it is trying to use macaroons if I specified explicitly in the lnd.conf not to use it. Also it is unclear why it can't generate macaroons DB if the directory clearly exists and the file permissions are correct.

anonproject commented 4 years ago

lnd.service

[Unit]
Description=LND Lightning Daemon
Requires=bitcoind.service
After=bitcoind.service

[Service]
ExecStart=/opt/lnd/lnd
ExecStop=/opt/lnd/lncli stop
PIDFile=/run/lnd/lnd.pid

User=satoshi
Group=satoshi

Type=simple
KillMode=process
TimeoutStartSec=60
TimeoutStopSec=60
Restart=always
RestartSec=60

# /run/satoshi
RuntimeDirectory=lnd
RuntimeDirectoryMode=0710

StandardOutput=journal

[Install]
WantedBy=multi-user.target
anonproject commented 4 years ago

/home/satoshi/.lnd/lnd.conf

[Application Options]
logdir=~/.lnd/logs
maxlogfiles=1
maxlogfilesize=10

no-macaroons=true

debuglevel=trace

[Bitcoin]
bitcoin.active=true
bitcoin.node=bitcoind

[Btcd]

[Bitcoind]
bitcoind.rpchost=127.0.0.1:19832
bitcoind.rpcuser=bitcoin
bitcoind.rpcpass=xxx
[neutrino]

[Litecoin]

[Ltcd]

[Litecoind]

[autopilot]

[tor]
[watchtower]

[wtclient]
wpaulino commented 4 years ago

Macaroons won't be created if you're running with the --no-macaroons flag. lncli doesn't read from the config file, so you need to specify it manually there as well: lncli --no-macaroons.

anonproject commented 4 years ago

Macaroons won't be created if you're running with the --no-macaroons flag. lncli doesn't read from the config file, so you need to specify it manually there as well: lncli --no-macaroons.

But the issue is not with lncli. The issue is that lnd cannot be started because it appear to call lncli internally.

Also I cannot quite understand what should I do with lncli yet. Right now I am just attempting to start a daemon.

anonproject commented 4 years ago

Macaroons won't be created if you're running with the --no-macaroons flag. lncli doesn't read from the config file, so you need to specify it manually there as well: lncli --no-macaroons.

I also attempted to run lnd with no-macaroons removed from lnd.conf. It doesn't seem to matter. I am getting the same error.

wpaulino commented 4 years ago

The issue is that lnd cannot be started because it appear to call lncli internally.

This isn't possible, lncli is likely being invoked due to your systemd service ExecStop=/opt/lnd/lncli stop. Once lnd is started, you need to create a wallet with lncli create.

I would suggest running lnd on its own without systemd until you get the hang of it.

anonproject commented 4 years ago

I am actually having an impression that lnd doesn't read the lnd.conf at all. I attempted to specify the path via --configfile option as used here: https://gist.github.com/bumi/c871a0bc082dc9bc9c5d1c19001d9a8d ... but it doesn't seem to support that option anymore.

anonproject commented 4 years ago

The issue is that lnd cannot be started because it appear to call lncli internally.

This isn't possible, lncli is likely being invoked due to your systemd service ExecStop=/opt/lnd/lncli stop. Once lnd is started, you need to create a wallet with lncli create.

I would suggest running lnd on its own without systemd until you get the hang of it.

Okay.

root@VS-48463:/home/satoshi/.lnd# sudo -u satoshi -H /opt/lnd/lnd create
Input wallet password:
Confirm password:

Do you have an existing cipher seed mnemonic you want to use? (Enter y/n): n

Your cipher seed can optionally be encrypted.
Input your passphrase if you wish to encrypt it (or press enter to proceed without a cipher seed passphrase):

Generating fresh cipher seed...

[lncli] unable to generate seed: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp 127.0.0.1:10009: connect: connection refused"
anonproject commented 4 years ago

Oh. So the create command of lnd just forwards it to lncli? Huh? That said, if I would attempt to run lnd without any arguments, I would get just this:

$ sudo -u satoshi -H /opt/lnd/lnd
NAME:
   lncli - control plane for your Lightning Network Daemon (lnd)

USAGE:
   lnd [global options] command [command options] [arguments...]

VERSION:
   0.9.1-beta commit=v0.9.1-beta

COMMANDS:
     getinfo     Returns basic information related to the active daemon.
     debuglevel  Set the debug level.
     stop        Stop and shutdown the daemon.
     help, h     Shows a list of commands or help for one command

   Autopilot:
     autopilot  Interact with a running autopilot.

   Channels:
     openchannel        Open a channel to a node or an existing peer.
     closechannel       Close an existing channel.
     closeallchannels   Close all existing channels.
     abandonchannel     Abandons an existing channel.
     channelbalance     Returns the sum of the total available channel balance across all open channels.
     pendingchannels    Display information pertaining to pending channels.
     listchannels       List all open channels.
     closedchannels     List all closed channels.
     getchaninfo        Get the state of a channel.
     getnetworkinfo     Get statistical information about the current state of the network.
     feereport          Display the current fee policies of all active channels.
     updatechanpolicy   Update the channel policy for all channels, or a single channel.
     exportchanbackup   Obtain a static channel back up for a selected channels, or all known channels
     verifychanbackup   Verify an existing channel backup
     restorechanbackup  Restore an existing single or multi-channel static channel backup

   Macaroons:                                                                                                                bakemacaroon  Bakes a new macaroon with the provided list of permissions and restrictions                          
   On-chain:
     estimatefee    Get fee estimates for sending bitcoin on-chain to multiple addresses.
     sendmany       Send bitcoin on-chain to multiple addresses.
     sendcoins      Send bitcoin on-chain to an address.
     listunspent    List utxos available for spending.
     listchaintxns  List transactions from the wallet.

   Payments:
     sendpayment     Send a payment over lightning.
     payinvoice      Pay an invoice over lightning.
     sendtoroute     Send a payment over a predefined route.
     addinvoice      Add a new invoice.
     lookupinvoice   Lookup an existing invoice by its payment hash.
     listinvoices    List all invoices currently stored within the database. Any active debug invoices are ignored.
     listpayments    List all outgoing payments.
     queryroutes     Query a route to a destination.
     decodepayreq    Decode a payment request.
     fwdinghistory   Query the history of all forwarded HTLCs.
     cancelinvoice   Cancels a (hold) invoice
     addholdinvoice  Add a new hold invoice.
     settleinvoice   Reveal a preimage and use it to settle the corresponding invoice.
     querymc         Query the internal mission control state.
     queryprob       Estimate a success probability.
     resetmc         Reset internal mission control state.
     buildroute      Build a route from a list of hop pubkeys.

   Peers:
     connect        Connect to a remote lnd peer.
     disconnect     Disconnect a remote lnd peer identified by public key.
     listpeers      List all active, currently connected peers.
     describegraph  Describe the network graph.
     getnodeinfo    Get information on a specific node.

   Startup:
     create          Initialize a wallet when starting lnd for the first time.
     unlock          Unlock an encrypted wallet at startup.
     changepassword  Change an encrypted wallet's password at startup.

   Wallet:
     newaddress     Generates a new address.
     walletbalance  Compute and display the wallet's current balance.
     signmessage    Sign a message with the node's private key.
     verifymessage  Verify a message signed with the signature.
     wallet         Interact with the wallet.

   Watchtower:
     tower     Interact with the watchtower.
     wtclient  Interact with the watchtower client.

GLOBAL OPTIONS:
   --rpcserver value          host:port of ln daemon (default: "localhost:10009")
   --lnddir value             path to lnd's base directory (default: "/home/satoshi/.lnd")
   --tlscertpath value        path to TLS certificate (default: "/home/satoshi/.lnd/tls.cert")
   --chain value, -c value    the chain lnd is running on e.g. bitcoin (default: "bitcoin")
   --network value, -n value  the network lnd is running on e.g. mainnet, testnet, etc. (default: "mainnet")
   --no-macaroons             disable macaroon authentication
   --macaroonpath value       path to macaroon file
   --macaroontimeout value    anti-replay macaroon validity time in seconds (default: 60)
   --macaroonip value         if set, lock macaroon to specific IP address
   --help, -h                 show help
   --version, -v              print the version
wpaulino commented 4 years ago

Looks like the lncli binary has been named as lnd. There are two distinct binaries: lnd which is the daemon itself, and lncli which is how you interact with the daemon.

This doesn't seem like an issue with the project, and more of a misconfiguration/misunderstanding on your part. I'd suggest joining our Slack for things like this if you still need help.

anonproject commented 4 years ago

Something definitely is very wrong here:

$ md5sum /opt/lnd/lnd
ab926781a342a737c4c8e60b1c7876ae  /opt/lnd/lnd
$ md5sum /opt/lnd/lncli
ab926781a342a737c4c8e60b1c7876ae  /opt/lnd/lncli
anonproject commented 4 years ago

Looks like the lncli binary has been named as lnd. There are two distinct binaries: lnd which is the daemon itself, and lncli which is how you interact with the daemon.

This doesn't seem like an issue with the project, and more of a misconfiguration/misunderstanding on your part. I'd suggest joining our Slack for things like this if you still need help.

Well, I took those binaries from the Asset section of your github repository.

So it is not misunderstanding on my part. It is a bug on your side. The lnd is the same as lncli. Huh.

anonproject commented 4 years ago

lnd-linux-amd64-v0.9.1-beta.tar.gz

wpaulino commented 4 years ago

I just downloaded the archive myself and confirmed the binaries are correct.

anonproject commented 4 years ago

I just downloaded the archive myself and confirmed the binaries are correct.

Uh oh.. I unpacked the archive and yes, the binaries are different now. Very strange. I wonder how the hell it happened. Sorry to disturb you. Thanks for the help.