1

I have a /ect/systemd/system/bitcoin.service with the following content and I am wondering, why bitcoin-cli getinfo tells me about a configuration file elsewhere:

error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/pi/.bitcoin/bitcoin.conf)

Content of bitcoin.service, especially -conf=/home/bitcoin/.bitcoin/bitcoin.conf:

[Unit]
Description=Bitcoin daemon
After=network.target
[Service]
ExecStart=/usr/local/bin/bitcoind -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid
# Creates /run/bitcoind owned by bitcoin
RuntimeDirectory=bitcoind
User=bitcoin
Type=forking
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid
Restart=on-failure
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target
  • bacause it not have the information for the rpc framework, this is an comple example of bitcoin.con, click me – vincenzopalazzo Aug 28 at 8:57
  • Thanks, I now understood that bitcoin-cli is a client to bitcoind and bitcoind has to run in server-mode which has to be specified in the config file along with username and password, right? – Ben Aug 28 at 9:00
  • yes, correct, I have answered inside this post with more details – vincenzopalazzo Aug 28 at 9:05
  • I posted both questions but I don't think they are related. The other question is mainly about bitcoin-init. – Ben Aug 28 at 9:49
  • yes, but include this question. – vincenzopalazzo Aug 28 at 9:51
0

The bitcoin-cli use the bitcoin-rpc, so for used a bitcoin-cli, you must ran the bitcoind with the configuration and when it is OK, you can get command with the bitcoin-cli

A simple file configuration could be it

##
## bitcoin.conf configuration file. Lines beginning with # are comments.
##
# On client-side, you add the normal user/password pair to send commands:
rpcuser=alice
rpcpassword=bob

or you can run the bitcoind with this command bitcoind -rpcuser=alice -rpcpassword=bob

0

bitcoin-cli has to be run with the same user as bitcoind.

Otherwise it will check for the configuration file in the wrong directory, because the default directory is the home directory of the user the process is run by.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.