cURL to Bitcoin-Qt on Mac fails

1

I followed gavinadresen's answer at Bitcoin-Qt command line control on Mac. When I enter the following in terminal, it works:

open Bitcoin-Qt.app --args -server

I've put in the following into my bitcoin.conf file:

rpcuser=yourname
rpcpassword=password

I entered the following in terminal:

curl --user yourname --data-binary '{"id":"t0", "method": "getinfo", "params": [] }' http://127.0.0.1:8332/

The above prompts me for the password and then it shows the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML>
<HEAD>
<TITLE>Error</TITLE>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
</HEAD>
<BODY><H1>401 Unauthorized.</H1></BODY>
</HTML>

The above output doesn't look right. Aren't I supposed to get data from Bitcoin? How do I get the curl command to work?

JLP

Posted 2014-01-23T05:21:49.330

Reputation: 209

Can you check if rpcssl=1 is set in the bitcoin.conf ? If so, bitcoin is excepting only HTTPS connections.Nontenda 2014-01-23T08:32:53.663

Answers

0

Three things to check :

  • Is there rpcssl=1 in your bitcoin.conf ? If so, set it to 0 or make HTTPS connections only
  • Have you set rpcallowip=127.0.0.1 ?
  • Try connect to http: //yourname:yourpassword@127.0.0.1:8332/ directly

And the fourth thing to check (as I saw your answer) :

  • Check if you have correctly entered your username and password ;)

Nontenda

Posted 2014-01-23T05:21:49.330

Reputation: 469

Please see my answer. I tried entering http://yourname:yourpassword@127.0.0.1:8332/ into my browser and got {"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}. How can I get this to work?

JLP 2014-01-23T14:57:50.210

Just edited my answer so ;) Indeed rcpallowip and rcpssl are not required but they can help you configure correctly your installNontenda 2014-01-23T15:20:39.567

0

I had screwed up. I entered the wrong yourname in

curl --user yourname --data-binary '{"id":"t0", "method": "getinfo", "params": [] }' http://127.0.0.1:8332/

as what I had entered for rpcuser= in my bitcoin.conf file.

When I entered the right yourname, the curl command responded with correct data from my bitcoin wallet.

I had tried entering the following into bitcoin.conf file but they were unnecessary and so I removed them:

rpcallowip=*
rpcallowip=127.0.0.1
rpcssl=1

JLP

Posted 2014-01-23T05:21:49.330

Reputation: 209