Skip to content

Instantly share code, notes, and snippets.

@tonymorony
Created October 14, 2018 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonymorony/886d411663b8612f0ae4077e73ad6e94 to your computer and use it in GitHub Desktop.
Save tonymorony/886d411663b8612f0ae4077e73ad6e94 to your computer and use it in GitHub Desktop.
bitcoin-cli rpc lib
Python bitcoin RPC lib which worked for me from box and took ~30 seconds to read doc and install:
pip3 install python-bitcoinrpc
ipython3
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:56212"%("user3150903419", "passe8fe2d8aa38c4e6faca129c6f3a6261a605e72a76eff36f2a5897dc7a03c2878b9"))
get_info = rpc_connection.getinfo()
print(get_info)
{'version': 1001550, 'protocolversion': 170003, 'KMDversion': '0.2.1', 'notarized': 0, 'prevMoMheight': 0, 'notarizedhash': '0000000000000000000000000000000000000000000000000000000000000000', 'notarizedtxid': '0000000000000000000000000000000000000000000000000000000000000000', 'notarizedtxid_height': 'mempool', 'KMDnotarized_height': 0, 'notarized_confirms': 0, 'walletversion': 60000, 'balance': Decimal('687990008.41585000'), 'blocks': 15185, 'longestchain': 15185, 'timeoffset': 0, 'tiptime': 1539502959, 'connections': 4, 'proxy': '', 'difficulty': Decimal('31.78766511598413'), 'testnet': False, 'keypoololdest': 1538718317, 'keypoolsize': 101, 'paytxfee': Decimal('0E-8'), 'relayfee': Decimal('0.00000100'), 'errors': '', 'CCid': 1, 'name': 'CCNG', 'p2pport': 56211, 'rpcport': 56212, 'magic': -918334085, 'premine': 1000, 'reward': 10000000000000}
In [7]: type(get_info)
Out[7]: dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment