2

According to the bitcoin documentation I can make curl calls to my bitcoin node. However, whenever I run a curl command like the following (as per the docs):

curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getbestblockhash", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/

I get no response. But when I run the bitcoin-cli edition:

bitcoin-cli getbestblockhash

I get a response.

So what is the difference? What am I missing?

I've seen this and this but they were never resolved.

2 Answers 2

5

Found it out, you just need to give it a username and password. You can add them to a bitcoin.conf file in your datadir. This file isn't automatically created. The default datadir is at ~/.bitcoin, so you can make a ~/.bitcoin/bitcoin.conf

rpcuser=user
rpcpassword=pass

Additionally, if you'd like, you can later pass your username and passwords as URL parameters, like so:

http://user:password@IP_ADDRESS:PORT
2

Keep in mind that the configuration file is not automatically created; you can create it using your favorite text editor. By default, the configuration file name is bitcoin.conf and it is located in the Bitcoin data directory, but both the Bitcoin data directory and the configuration file path may be changed using the -datadir and -conf command-line options. Also, do not forget to set the appropriate file permissions and restart the bitcoind.

Your Answer

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

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