def getblock(self, block_hash): """Get block <block_hash> Raises IndexError if block_hash is not valid. """ try: block_hash = b2lx(block_hash) except TypeError: raise TypeError('%s.getblock(): block_hash must be bytes; got %r instance' % (self.__class__.__name__, block_hash.__class__)) try: r = self._call('getblock', block_hash, False) except JSONRPCException as ex: raise IndexError('%s.getblock(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code'])) return CAltcoinBlock.deserialize(unhexlify(r))
def getblock(self, block_hash): """Get block <block_hash> Raises IndexError if block_hash is not valid. """ try: block_hash = b2lx(block_hash) except TypeError: raise TypeError( '%s.getblock(): block_hash must be bytes; got %r instance' % (self.__class__.__name__, block_hash.__class__)) try: r = self._call('getblock', block_hash, False) except JSONRPCException as ex: raise IndexError('%s.getblock(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code'])) return CAltcoinBlock.deserialize(unhexlify(r))
#!/usr/bin/env python3 # Copyright (C) 2015 The python-altcoinlib developers # # This file is part of python-altcoinlib. # # It is subject to the license terms in the LICENSE file found in the top-level # directory of this distribution. # # No part of python-bitcoinlib, including this file, may be copied, modified, # propagated, or distributed except according to the terms contained in the # LICENSE file. """Take a list of blocks and deserializes them""" import sys from altcoin.core import CAltcoinBlock from bitcoin.core import x for block in sys.argv[1:]: print(CAltcoinBlock.deserialize(x(block)))
#!/usr/bin/env python3 # Copyright (C) 2015 The python-altcoinlib developers # # This file is part of python-altcoinlib. # # It is subject to the license terms in the LICENSE file found in the top-level # directory of this distribution. # # No part of python-bitcoinlib, including this file, may be copied, modified, # propagated, or distributed except according to the terms contained in the # LICENSE file. """Take a list of blocks and deserializes them""" import sys from altcoin.core import CAltcoinBlock from bitcoin.core import x for block in sys.argv[1:]: print (CAltcoinBlock.deserialize(x(block)))