I created a ~/.bitcoin/.cookie file with the line
rpcuser:rpcpassword
However I get from electrs
reconnecting to bitcoind: no reply from daemon
and from bitcoin debug.log
ThreadRPCServer incorrect password attempt from 127.0.0.1:59596
What am I doing wrong?
I found out that reading the password from the .cookie file does not work with a custom rpc username and rpcpassword. However I would like to set a custom username and password.
You should run bitcoind with the -rpcpassword and -rpcuser parameters (or set them in the bitcoin.conf file).
See https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File.
In electrs, you can use the config file to set the custom cookie as USER:PASSWORD:
https://github.com/romanz/electrs/blob/1498eed6bb07c029eef07bad43a4eb2c37e7d188/config_spec.toml#L35
You should run
bitcoindwith the-rpcpasswordand-rpcuserparameters (or set them in thebitcoin.conffile).
See https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File.
Inelectrs, you can use the config file to set the custom cookie asUSER:PASSWORD:https://github.com/romanz/electrs/blob/1498eed6bb07c029eef07bad43a4eb2c37e7d188/config_spec.toml#L35
I did specify the rpcuser and rpcpassword in the bitcoin.conf (and had in the past other services connect successfully to bitcoind). I copied the username and password manually to ~/bitcoin/.cookie (username:password), but still electrs was unable to connect to bitcoind.
In the past I was able to connect electrs using the commandline option "cookie" (Specifying the username and password in the commandline when starting electrs). However this commandline option was removed from electrs recently.
How do you specify a custom rpcuser and rpcpassword and pass it to electrs?
You can also use --cookie-file added by #191.
Thanks. But I tried this already too without success. The only option for me is currently to remove the custom user and password.
I think it should work with the latest version.
For example, set the following flags in bitcoin.conf:
rpcuser=user
rpcpassword=8WGfCK981eYio5MnsIqajB4SJnwGFI9oHc
Then, set the following cookie file for electrs:
$ echo "user:8WGfCK981eYio5MnsIqajB4SJnwGFI9o" > auth.cookie
$ electrs --cookie-file=auth.cookie
I tried exactly this again (a different alphanumeric password though) and get the same error message
WARN - reconnecting to bitcoind: no reply from daemon
and bitcoins debug.log
ThreadRPCServer incorrect password attempt from 127.0.0.1:40064
Please make sure that the cookie file doesn't end with EOL, i.e. (note the -n)
$ echo -n "user:8WGfCK981eYio5MnsIqajB4SJnwGFI9o" > auth.cookie
Sorry for the confusion...
This works! Thanks! I guess every editor I edited created a EOL without me noticing.
Would it be worth it to improve the cookie reader to handle an EOL?