A constant RPC_CREDENTIALS is introduced that determines the RPC authentication method: if credentials are set (i.e. Some(user, pass)), user-pass-authentication is used, otherwise (i.e. None), authentication is cookie-based.
Note that by now the cookie-file is assumed to reside in ~/.bitcoin/regtest/.cookie and thus this authentication method will only work for Linux (also *BSD I guess?) and regtest network. Tested successfully with Debian 10 and Bitcoin Core 0.21.0.
If this PR gets accepted, there are a few possible follow-ups I could think of:
put RPC_CREDENTIALS (and probably other constants) in a separate source file to avoid conflicts during development if changes in main.rs are done and cookie-base auth is used (short-term)
support reading in a configuration file (long-term)
mention this authentication method in README.md
obviously: also make this work for other OSes and Bitcoin networks
This PR is a first step towards supporting cookie-based RPC authentication, as offered by Bitcoin Core since v0.12.
A constant
RPC_CREDENTIALS
is introduced that determines the RPC authentication method: if credentials are set (i.e.Some(user, pass)
), user-pass-authentication is used, otherwise (i.e.None
), authentication is cookie-based.Note that by now the cookie-file is assumed to reside in
~/.bitcoin/regtest/.cookie
and thus this authentication method will only work for Linux (also *BSD I guess?) and regtest network. Tested successfully with Debian 10 and Bitcoin Core 0.21.0.If this PR gets accepted, there are a few possible follow-ups I could think of:
RPC_CREDENTIALS
(and probably other constants) in a separate source file to avoid conflicts during development if changes in main.rs are done and cookie-base auth is used (short-term)README.md