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)
| 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): |
nothing calls this directly
no test coverage detected