Bitcoin RPC returning 401

1

I am using node-bitcoin-rpc to do some api calls to bitcoind, but I am getting 401 error. I know this simply means unauthorized, but I have no authorization enable in my config file.

Howerver I can query bitcoin client using vitcoin-cli --regtest listaccounts, I get the results.

My bitcoin.conf file is pretty simple

rpcport=8332
rpcconnect=127.0.0.1
regtest=1
debug=rpc

PS: I didn't have any bitcoin.conf initially, so I create above one inside .bitcoin folder in home directory.

Prashant Prabhakar Singh

Posted 2018-07-15T07:23:28.973

Reputation: 161

Answers

1

The RPC interface is an authenticated interface. You need to provide a username and password in order to send RPC commands. These are usually specified in the bitcoin.conf file with the rpcuser and rpcpassword options or the rpcauth option. There are also temporary RPC credentials stored in the .cookie file that can be found in the datadir.

The reason that you have no problems with bitcoin-cli is because it looks up the RPC credentials from the bitcoin.conf file or the .cookie file..

Andrew Chow

Posted 2018-07-15T07:23:28.973

Reputation: 40 910