Ejemplo n.º 1
0
def deserialize_tx(tx_hash, tx_height, raw_tx):
    vds = deserialize.BCDataStream()
    vds.write(raw_tx.decode('hex'))
    tx = deserialize.parse_Transaction(vds)
    tx['height'] = tx_height
    tx['tx_hash'] = tx_hash
    return tx
Ejemplo n.º 2
0
def parse_block(raw_block):
    vds = deserialize.BCDataStream()
    vds.write(raw_block)
    block = deserialize.parse_BlockHeader(vds)
    block["transactions"] = []
    number_tx = vds.read_compact_size()
    for i in xrange(number_tx):
        tx = deserialize.parse_Transaction(vds)
        block["transactions"].append(tx)
    return block
 def get_mempool_transaction(self, txid):
     try:
         raw_tx = self.quebecoind('getrawtransaction', (txid, 0))
     except:
         return None
     vds = deserialize.BCDataStream()
     vds.write(raw_tx.decode('hex'))
     try:
         return deserialize.parse_Transaction(vds, is_coinbase=False)
     except:
         print_log("ERROR: cannot parse", txid)
         return None
 def deserialize_block(block):
     txlist = block.get('tx')
     tx_hashes = []  # ordered txids
     txdict = {}  # deserialized tx
     is_coinbase = True
     for raw_tx in txlist:
         tx_hash = hash_encode(Hash(raw_tx.decode('hex')))
         vds = deserialize.BCDataStream()
         vds.write(raw_tx.decode('hex'))
         try:
             tx = deserialize.parse_Transaction(vds, is_coinbase)
         except:
             print_log("ERROR: cannot parse", tx_hash)
             continue
         tx_hashes.append(tx_hash)
         txdict[tx_hash] = tx
         is_coinbase = False
     return tx_hashes, txdict
Ejemplo n.º 5
0
 def deserialize(self):
     import deserialize
     vds = deserialize.BCDataStream()
     vds.write(self.raw.decode('hex'))
     self.d = deserialize.parse_Transaction(vds)
     return self.d
Ejemplo n.º 6
0
def parse_transaction(raw_tx):
    vds = deserialize.BCDataStream()
    vds.write(raw_tx)
    tx = deserialize.parse_Transaction(vds)
    tx["hash"] = deserialize.Hash(raw_tx)[::-1]
    return tx