I'm starting with python-bitcoinrpc from J.Garzik.
I'm using to try it the code provided by James D'Angelo (from Bitcoin 101 on youtube):
Apparently, there were some major changes with python-bitcoinrpc, not taken into account by old tutorial as the ones from James since you don't do now:
from bitcoinrpc.util import * from bitcoinrpc.exceptions import * from bitcoinrpc.__init__ import * from bitcoinrpc.config import * from bitcoinrpc.proxy import * from bitcoinrpc.data import * from bitcoinrpc.connection import * bitcoin = connect_to_local() NEW_ADDRESS = bitcoin.getnewaddress() print(NEW_ADDRESS)
from bitcoinrpc.authproxy import AuthServiceProxy access = AuthServiceProxy() info = access.getinfo() # Not WORKING: info is None
That's okay for me, and very shorter.
The problem is to get
access.getinfo()to a variable? According to the README from python-bitcoinrpc, you can use the logging module to print stderr to the screen
logging.basicConfig() logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG) rpc_connection = AuthServiceProxy("http://%s:%firstname.lastname@example.org:8332"%(rpc_user, rpc_password)) print(rpc_connection.getinfo())
But how do you put that into a variable?? Like with:
info = access.getinfo()
(which is not working: