MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / getblockheader

Method getblockheader

bitcoin/rpc.py:458–488  ·  view source on GitHub ↗

Get block header 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.

(self, block_hash, verbose=False)

Source from the content-addressed store, hash-verified

456 return lx(self._call('getbestblockhash'))
457
458 def getblockheader(self, block_hash, verbose=False):
459 """Get block header <block_hash>
460
461 verbose - If true a dict is returned with the values returned by
462 getblockheader that are not in the block header itself
463 (height, nextblockhash, etc.)
464
465 Raises IndexError if block_hash is not valid.
466 """
467 try:
468 block_hash = b2lx(block_hash)
469 except TypeError:
470 raise TypeError('%s.getblockheader(): block_hash must be bytes; got %r instance' %
471 (self.__class__.__name__, block_hash.__class__))
472 try:
473 r = self._call('getblockheader', block_hash, verbose)
474 except InvalidAddressOrKeyError as ex:
475 raise IndexError('%s.getblockheader(): %s (%d)' %
476 (self.__class__.__name__, ex.error['message'], ex.error['code']))
477
478 if verbose:
479 nextblockhash = None
480 if 'nextblockhash' in r:
481 nextblockhash = lx(r['nextblockhash'])
482 return {'confirmations':r['confirmations'],
483 'height':r['height'],
484 'mediantime':r['mediantime'],
485 'nextblockhash':nextblockhash,
486 'chainwork':x(r['chainwork'])}
487 else:
488 return CBlockHeader.deserialize(unhexlify_str(r))
489
490
491 def getblock(self, block_hash):

Callers

nothing calls this directly

Calls 6

b2lxFunction · 0.90
lxFunction · 0.90
xFunction · 0.90
unhexlify_strFunction · 0.85
_callMethod · 0.45
deserializeMethod · 0.45

Tested by

no test coverage detected