Skip to content

config: support reading bitcoin rpc password from a file - #253

Merged
ViktorT-11 merged 2 commits into
lightninglabs:masterfrom
Roasbeef:bitcoin-passwordfile
Sep 3, 2026
Merged

ViktorT-11 merged 2 commits into
lightninglabs:masterfrom
Roasbeef:bitcoin-passwordfile

Conversation

@Roasbeef

@Roasbeef Roasbeef commented Sep 2, 2026

Copy link
Copy Markdown
Member

Summary

Adds a --bitcoin.passwordfile config option as an alternative to
--bitcoin.password, so operators can point faraday at a file
containing the bitcoind/btcd RPC password instead of putting it in
plaintext on the command line or in a docker-compose manifest.

  • chain.BitcoinConfig gains a PasswordFile field
    (--bitcoin.passwordfile).
  • ValidateConfig resolves the password from the file when
    --bitcoin.passwordfile is set, trimming surrounding whitespace and
    the trailing newline, and rejects the config if both
    --bitcoin.password and --bitcoin.passwordfile are set, if the
    file can't be read, or if it's empty.
  • README documents the new flag.

Closes #252.

Test plan

  • go build ./...
  • go vet ./...
  • go test -race . (new TestValidateConfigBitcoinPassword covers
    the plaintext flag, the file flag, a missing file, an empty
    file, and the mutually-exclusive-flags case)
  • go test ./... (itest failures are pre-existing/unrelated —
    that suite requires a live bitcoind/lnd docker environment)

Add a --bitcoin.passwordfile flag as an alternative to
--bitcoin.password, so operators can avoid putting the bitcoind/btcd
RPC password in plaintext on the command line or in shell history.

Fixes lightninglabs#252.
An empty or whitespace-only password file previously fell through to
the generic 'rpc user and password required' error, which is
misleading when the operator did pass --bitcoin.passwordfile. Fail
with a message pointing at the file instead.

Also document that surrounding whitespace and the trailing newline
are stripped from the file's contents.

@bitromortac bitromortac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM tACK 🎉

@NicolasDorier

NicolasDorier commented Sep 3, 2026 •

Copy link
Copy Markdown

@Roasbeef I wished I'd get that for LND too. Because LND didn't handle change of cookie value at run time, I needed to configure a fixed password.

I will handle that in our docker-entrypoint.sh of our own image for now, but having it in LND would be very nice. (either that, or having your RPC client re-fetch automatically the __cookie__ pwd when the auth fails)

@ViktorT-11 ViktorT-11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM 🙏

@ViktorT-11
ViktorT-11 merged commit 1afc5f4 into lightninglabs:master Sep 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can you support reading password from a file?

4 participants