Enhance `btcd/btcutil`'s `appDataDir` to support a CLI flag to programatically obtain config-directory path
Background / Motivation
Currently daemons using btcutil (litd, loop, pool, tapd, lnd) have operating-system specific configuration directory paths.
- Anytime guides are written or the conf file needs to addressed, there's a need to preface where these files are located https://github.com/lightninglabs/lightning-terminal/blob/ba81aaf0d797844efc72a20dcdb71edc9d5b4a9b/doc/config-lnd-remote.md?plain=1#L27-L32
Create a `lit.conf` file. The default location LiT will look for the configuration file
depends on your operating system:
- MacOS: `~/Library/Application Support/Lit/lit.conf`
- Linux: `~/.lit/lit.conf`
- Windows: `~/AppData/Roaming/Lit/lit.conf`
- and sometimes guides are have incomplete / error-prone conf information https://github.com/lightninglabs/docs.lightning.engineering/blob/261a1b8ebce1b5d1d027eb7f98c391031b67d562/lightning-network-tools/lightning-terminal/run-litd.md?plain=1#L21-L22
User: This guide failed because I did what it said and litd didn't find the conf file (because the user wasn't on linux and didn't know the macOS conf location)
-
Other node-automation services have to manage determining where to place the conf file e.g. produce
unamebash scripts. -
If the lnd/litd process has been started with a
--lnddirset at runtime, the conf file location won't match what's listed in the guides
Solution
A CLI flag which reports btcd/btcutil's appDataDir would enable programmatically obtaining the config-directory path
e.g. litd --conf-prefix
would return the configuration-file directory
Enabling programmatic access:
touch $(litd --conf-prefix)/lit.conf
# or
<<<"lnd-mode=remote" >> $(litd --conf-prefix)/lit.conf
If --conf-prefix is considered a departure from existing nomenclature standards, An alternative name might be --lnd-dir-prefix
Obviate the human in the loop to determine the location!
References
Homebrew uses a similar flag
$ brew --prefix
/opt/homebrew
and is often used
If btcd isn't the ideal location for this issue, it will be moved
the main pitch is: Don't you want to live in a world where we can tell anyone, regardless of their OS:
Run this in your terminal
<<<"lnd-mode=remote" >> $(litd --conf-prefix)/lit.conf
Rather than
Ok if you are using linux
<<<"lnd-mode=remote" >> ~/.lit/lit.confoh you're on macOS? oh then you should do<<<"lnd-mode=remote" >> ~/Library/Application Support/Lit/lit.conf