Skip to content

GetInfo Depreciated so I added function in order to replace it #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions bitcoin/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ def getblockheader(self, block_hash, verbose=False):
verbose - If true a dict is returned with the values returned by
getblockheader that are not in the block header itself
(height, nextblockhash, etc.)

Raises IndexError if block_hash is not valid.
"""
try:
Expand All @@ -458,7 +457,7 @@ def getblockheader(self, block_hash, verbose=False):
r = self._call('getblockheader', block_hash, verbose)
except InvalidAddressOrKeyError as ex:
raise IndexError('%s.getblockheader(): %s (%d)' %
(self.__class__.__name__, ex.error['message'], ex.error['code']))
(self.__class__.__name__, ex, ex.RPC_ERROR_CODE ))

if verbose:
nextblockhash = None
Expand Down Expand Up @@ -490,7 +489,7 @@ def getblock(self, block_hash):
r = self._call('getblock', block_hash, False)
except InvalidAddressOrKeyError as ex:
raise IndexError('%s.getblock(): %s (%d)' %
(self.__class__.__name__, ex.error['message'], ex.error['code']))
(self.__class__.__name__, ex, ex.RPC_ERROR_CODE))
return CBlock.deserialize(unhexlify(r))

def getblockcount(self):
Expand All @@ -506,7 +505,7 @@ def getblockhash(self, height):
return lx(self._call('getblockhash', height))
except InvalidParameterError as ex:
raise IndexError('%s.getblockhash(): %s (%d)' %
(self.__class__.__name__, ex.error['message'], ex.error['code']))
(self.__class__.__name__, ex, ex.RPC_ERROR_CODE))

def getinfo(self):
"""Return a JSON object containing various state info"""
Expand All @@ -516,11 +515,28 @@ def getinfo(self):
if 'paytxfee' in r:
r['paytxfee'] = int(r['paytxfee'] * COIN)
return r

def getnetworkinfo(self):
"""Return a JSON object containing information about the network"""
return self._call('getnetworkinfo')

def getwalletinfo(self):
"""Return a JSON object containing information about the wallet"""
r = self._call('getwalletinfo')
if 'balance' in r:
r['balance'] = int(r['balance'] * COIN)
if 'paytxfee' in r:
r['paytxfee'] = int(r['paytxfee'] * COIN)
return r

def getmininginfo(self):
"""Return a JSON object containing mining-related information"""
return self._call('getmininginfo')

def getblockchaininfo(self):
"""Return a JSON object containing Blockchain-related information"""
return self._call('getblockchaininfo')

def getnewaddress(self, account=None):
"""Return a new Bitcoin address for receiving payments.

Expand Down Expand Up @@ -568,7 +584,7 @@ def getrawtransaction(self, txid, verbose=False):
r = self._call('getrawtransaction', b2lx(txid), 1 if verbose else 0)
except InvalidAddressOrKeyError as ex:
raise IndexError('%s.getrawtransaction(): %s (%d)' %
(self.__class__.__name__, ex.error['message'], ex.error['code']))
(self.__class__.__name__,ex, ex.RPC_ERROR_CODE))
if verbose:
r['tx'] = CTransaction.deserialize(unhexlify(r['hex']))
del r['hex']
Expand Down Expand Up @@ -611,7 +627,7 @@ def gettransaction(self, txid):
r = self._call('gettransaction', b2lx(txid))
except InvalidAddressOrKeyError as ex:
raise IndexError('%s.getrawtransaction(): %s (%d)' %
(self.__class__.__name__, ex.error['message'], ex.error['code']))
(self.__class__.__name__, ex, ex.RPC_ERROR_CODE))
return r

def gettxout(self, outpoint, includemempool=True):
Expand Down