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
  • 229
  • 5
  • 13
  • Can you check if rpcssl=1 is set in the bitcoin.conf ? If so, bitcoin is excepting only HTTPS connections. – Nontenda Jan 23 '14 at 08:32

2 Answers2

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
  • 529
  • 4
  • 9
  • 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 Jan 23 '14 at 14:57
  • Just edited my answer so ;) Indeed rcpallowip and rcpssl are not required but they can help you configure correctly your install – Nontenda Jan 23 '14 at 15:20
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
  • 229
  • 5
  • 13