1

I am new to python-bitcoinrpc(also new to VM Linux actually) and I want to use the blockchain parser from alecalve to get ordered blocks. I used Windows to download the blockchain data into an external hard drive as well as bitcoin.conf but then I found that this parser could only be used on Linux, so I downloaded Bitcoin Core again on Linux and run

./bitcoin-qt -datadir=/media/myharddrive/Bitcoin -conf=/media/myharddrive/Bitcoin/bitcoin.conf

to avoid re-downloading the data.

However, it seems I cannot connect to rpc because the simple code

rpc_connection = AuthServiceProxy("http://%s:%[email protected]:8332"%('rpcuser', 'myrpcpassword'))

best_block_hash = rpc_connection.getbestblockhash()

returns error like this

Traceback (most recent call last):
  File "process1.py", line 129, in <module>
    parser(block)
  File "process1.py", line 62, in parser
    prevtxhex = rpc_connection.getrawtransaction(prevtxidhash,0)
  File "/home/lylian/.local/lib/python3.8/site-packages/bitcoinrpc/authproxy.py", line 132, in __call__
    self.__conn.request('POST', self.__url.path, postdata,
  File "/usr/lib/python3.8/http/client.py", line 1230, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1276, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1225, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1004, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 944, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 915, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.8/socket.py", line 808, in create_connection
    raise err
  File "/usr/lib/python3.8/socket.py", line 796, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I wonder if it's because my code cannot find bitcoin.conf(I put it both in the default location and my hard drive) or there is something wrong with my settings.

rpcuser=xxx
rpcpassword=xxx
server=1

Thanks very much!!

3
  • can you upload also your bitcoin.conf? Commented Apr 30, 2020 at 17:59
  • already did, it's just simple...
    – Lylian
    Commented May 1, 2020 at 2:05
  • add rpcuser=sandbox , rpcpassword=sendbox, rpcport=8332 bind=127.0.0.1 and you can use this python script to test the node with python Commented May 1, 2020 at 3:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.