lightningnetwork / lnd

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

[feature]: `lncli --lnddir=` doesn't fetch the `rpclisten` from `lnd.conf` #7843

Open AndySchroder opened 1 year ago

AndySchroder commented 1 year ago

Background

lncli --lnddir= doesn't fetch the rpclisten from lnd.conf

Your environment

Expected behaviour

lncli should read the lnd.conf file in the specified lnddir and use the rpclisten value for the rpcserver.

Actual behaviour

The default value of 10009 is used for rpcserver instead.

I think that the rpcserver option should be usable to override a value found in the lnd.conf file in the specified lnddir=, but it should not be required.

Right now I feel like rpcserver needs to be duplicately defined if you are using the --lnddir option with lncli.

hieblmi commented 1 year ago

Thanks for reporting @AndySchroder. Indeed --lnddir is currently only used to instruct lncli where the macaroon and tls cert paths are to be found, see https://github.com/lightningnetwork/lnd/blob/master/cmd/lncli/main.go#L302

For now you have to specify --rpcserver or other config params via the command line parameters. Feel free to convert this ticket into a feature request or otherwise you could also close this issue.

AndySchroder commented 1 year ago

Okay, I changed the title to say feature instead of bug.

josephawallace commented 1 year ago

It's not always the case that lnd and lncli will run on the same machine, so rpclisten would be mislabeled if it's being used as the host for lncli to connect to. Perhaps a better solution is to add a profile to lncli that specifies the rpc server.

Something like this: lncli --rpcserver <lnd_rpc_host> --opt1 <opt1> --opt2 <opt2> ... profile add --name <profile_name>

Then, when you want to make a call using those options, you can do so using: lncli -p <profile_name> <command>