Creative crypter
Creative crypter

Reputation: 1516

Bitcoin RPC authentication issue - regtest

i am currently developing a bitcoin application which involves running a full bitcoin node.

As i am testing my source code, i decided to use the bitcoin regtest mode.

This is how i start my bitcoin node:

./bitcoind -regtest -rpcuser=a -rpcpassword=b -server -bind=0.0.0.0

This is how i am interacting with my regtest node:

./bitcoin-cli -regtest -rpcuser=a -rpcpassword=b getnewaddress

Output:

2N152jpoD9u52cpswsN7ih8RZ3P4DszaUGg

This example works as expected... BUT !

As soon as i try to interact with bitcoin node not using bitcoin-cli, but curl or python i get stuck:

curl --user a --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://192.168.178.200:18444/

i get asked for the password => i enter b

and then it says:

curl: (52) Empty reply from server

same for:

curl --user a:b --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://192.168.178.200:18444/

and:

curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://a:[email protected]:18444/

I also looked for a cookie file to authenticate with cookie, but there was none.

i already researched the problem, e.g.

https://bitcoin.stackexchange.com/questions/22335/bitcoin-daemon-sends-empty-reply-from-server-when-in-test-net

and various other sites, but none helped...

i am running version 0.18.0

Well, i described my problem in detail and mentioned what i already tried for two days..

Any suggestions?

Thanks and Greetings!

Upvotes: 6

Views: 2192

Answers (1)

Bhanu Agrawal
Bhanu Agrawal

Reputation: 71

We should update the regtest RPC port if the version is >= 0.16.0 to 18443. So, I just changed the port from 18444 to 18443, it worked.

Example:

curl --user username:password --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockhash","params":[0]}' -H 'content-type:text/plain;' http://127.0.0.1:18443

Ref: https://github.com/ruimarinho/bitcoin-core/issues/60

Upvotes: 3

Related Questions