5

I'm running a bitcoind 0.16 and it seem working, blockchain in sync etc.. I've used the "new" rpcauth, which is non deprecated so kind of referennce as explained here: https://github.com/bitcoin/bitcoin/blob/v0.16.0/contrib/debian/examples/bitcoin.conf. I've generated the rpcauth line and the password with ./share/rpcauth/rpcauth.py bob

Copied the rpc line in the ~/.bitcoin/bitcoin.conf file and stored the password elsewhere. The conf file have this [rpc] section:

server=1
rest=1
rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99

I run

./src/bitcoin-cli get blockchaininfo -rpcuser={...} -rpcpassword={...}

The answer is:

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/bitcoin/.bitcoin/bitcoin.conf)

It's like the cli can't read the rpc credentials from the command line. It's not saying "credentials are wrong". Also the conf file is the correct one so...

Any clue?

3 Answers 3

9

You are using bitcoin-cli incorrectly.

The command line arguments come before the RPC command. Anything that comes after the RPC command will be interpreted as arguments for the RPC, not arguments to bitcoin-cli

So what you should actually be doing is

src/bitcoin-cli -rpcuser={...} -rpcpassword={...} getblockchaininfo
1
  • Rather: src/bitcoin-cli -rpcuser={...} -rpcpassword={...} getblockchaininfo May 11, 2019 at 16:13
2

The "accepted answer" is technically correct but it's INCORRECT in its reasoning and doesn't explain that there are actually 2 RPC auth methods for bitcoind (which bitcoin-cli communicates with).

The commandline -rpcuser and -rpcpassword are NOT FOR rpcauth accounts. That's the first problem that was never mentioned in the accepted answer.

It also failed to mention that you cannot use rpcauth creds from the bitcoin-cli command line app. Bitcoind has 2 RPC auth methods, only 1 of them is available via command line and that's the old one that's going to be removed. After that, you're screwed. No more command line access to bitcoind via bitcoin-cli (like that makes any sense ...). You'll have to create your own script and connect to it over the RPC port without the use of bitcoin-cli from what I can tell.

For now you have to use rpcuser and rpcpass either on the command line or in bitcoin.conf file. Perhaps rpcauth support will be added to the command line in the future for but at the moment, it doesn't appear like that's going to happen.

Anyway if anyone can actually show a real answer to this (that uses rpcauth from the bitcoin-cli command line app), feel free. I see no way to use rpcauth from command line bitcoin-cli at the moment. It looks like https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py is going to replace it but currently all it does is generate passwords. That's pretty useless as far as actually using any pre-built command line apps for communicating with bitcoind is concerned.

0

Try to use the old authentication way which i always been using and has no issue

#rpcuser=USER
#rpcpassword=PASS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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