I'm running bitcoind/ bitcoind -regtest on Windows 10 and am already able to use bitcoin-cli -regtest along with json-rpc methods to perform basic operations and get balances etc. When I try to do this programmatically on python 3 using Jeff Garzik's python-bitcoinrpc package (https://github.com/jgarzik/python-bitcoinrpc) I get a modulenotfounderror. However, my pip3 freeze shows python-bitcoinlib==0.10.1 and also python-bitcoinrpc==1.0.
My code is below (18443 is the regtest port):
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
rpc_connection = AuthServiceProxy("http://%s:%firstname.lastname@example.org:18443"%("myrpcuser","myrpcpassword"))
best_block_hash = rpc_connection.getbestblockhash() print(rpc_connection.getblock(best_block_hash))
What am I doing wrong?
Separately, is there a way to make the json-rpc calls into bitcoind directly from python3 instead of using this library, since it seems really old and out of use? Very grateful for your kind help!