Exemplo n.º 1
0
 def getHash(self, endian=LITTLEENDIAN):
    if self.version == UNINITIALIZED:
       raise UnitializedBlockDataError, 'PyBlockHeader object not initialized!'
    if len(self.theHash) < 32:
       self.theHash = hashX11(self.serialize())
    outHash = self.theHash
    if endian==BIGENDIAN:
       outHash = binary_switchEndian(outHash)
    return outHash
Exemplo n.º 2
0
   def unserialize(self, toUnpack):
      if isinstance(toUnpack, BinaryUnpacker):
         blkData = toUnpack
      else:
         blkData = BinaryUnpacker( toUnpack )

      self.version     = blkData.get(UINT32)
      self.prevBlkHash = blkData.get(BINARY_CHUNK, 32)
      self.merkleRoot  = blkData.get(BINARY_CHUNK, 32)
      self.timestamp   = blkData.get(UINT32)
      self.diffBits    = blkData.get(BINARY_CHUNK, 4)
      self.nonce       = blkData.get(UINT32)
      self.theHash     = hashX11(self.serialize())
      return self
Exemplo n.º 3
0
 def getHashHex(self, endian=LITTLEENDIAN):
    if self.version == UNINITIALIZED:
       raise UnitializedBlockDataError, 'PyBlockHeader object not initialized!'
    if len(self.theHash) < 32:
       self.theHash = hashX11(self.serialize())
    return binary_to_hex(self.theHash, endian)