jgarzik / python-bitcoinrpc

Python interface to bitcoin's JSON-RPC API
GNU Lesser General Public License v2.1
642 stars 307 forks source link

Python Bitcoin-RPC Connection Error? #101

Closed datadimes closed 4 years ago

datadimes commented 4 years ago

My node is fully sync'd and operational (I've confirmed via commands with ssh) and I'm hoping to now use python-bitcoinrpc to interact with my node. Unfortunately I didn't get very far. Here is the code I'm running:

from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%(rpc_user, rpc_password)) best_block_hash = rpc_connection.getbestblockhash()

Where rpc_user and rpc_password is exactly what's in my bitcoin.conf file.

I disabled the ufw from the Raspibolt setup, but still getting the same error. My hunch is that it has to do with the port and since the Raspibolt setup is with Tor. Here is the info from my bitcoin.conf file:

server=1
txindex=1

# Network
listen=1
listenonion=1
proxy=127.0.0.1:9050
bind=127.0.0.1

# Connections
rpcuser=[rpcuser]
rpcpassword=[rpcpassword]
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

# Raspberry Pi optimizations
maxconnections=40
maxuploadtarget=5000

# Initial block download optimizations
dbcache=2000
blocksonly=1

I've been tweaking the address and port but still receive same error. Obviously a bit of a novice here but hoping to learn more!

jodobear commented 4 years ago

what exact error do you get?

datadimes commented 4 years ago

what exact error do you get?

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

datadimes commented 4 years ago

Resolved - was able to use the nano text editor with the raspberry pi with the above code and it's now working with no issues.