2

Tryed to run this code :

from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
import logging
import json

logging.basicConfig()
logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG)

rpc_connection = AuthServiceProxy("http://%s:%[email protected]:18332"%('user', 'password'))
print(rpc_connection.getinfo())

with my pass and my username but I have this error:

DEBUG:BitcoinRPC:-1-> getinfo [] Traceback (most recent call last): File "/home/conio/Scrivania/conioclass/conio/components/provaRPC.py", line 9, in <module> print(rpc_connection.getinfo()) File "/home/conio/Scrivania/conioclass/conio/components/bitcoinrpc/authproxy.py", line 139, in __call__ response = self._get_response() File "/home/conio/Scrivania/conioclass/conio/components/bitcoinrpc/authproxy.py", line 187, in _get_response 'code': -342, 'message': 'non-JSON HTTP response with \'%i %s\' from server' % (http_response.status, http_response.reason)}) bitcoinrpc.authproxy.JSONRPCException: -342: non-JSON HTTP response with '401 Unauthorized' from server

Can you help me?

1
  • Fixed... there were some problems in the bitcoin.conf file Commented Aug 23, 2016 at 12:44

1 Answer 1

1

Indeed to use bitcoinrpc, you need to set the username and password in bitcoin.conf by:

rpcauth=user:salt$hash of password

which you can generate using https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py. Simply shutdown bitcoind, add this to bitcoin.conf, restart, and you'll immediately be able to run commands in python like

print(rpc_connection.getinfo())

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.