Exemple #1
0
def _dump_tx(datadir, tx_hash, tx_pos):
  blockfile = open(os.path.join(datadir, "blk%04d.dat"%(tx_pos[0],)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, tx_pos[2])
  d = parse_Transaction(ds)
  print deserialize_Transaction(d)
  ds.close_file()
  blockfile.close()
Exemple #2
0
def _dump_tx(datadir, tx_hash, tx_pos):
  blockfile = open(os.path.join(datadir, "blk%04d.dat"%(tx_pos[0],)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, tx_pos[2])
  d = parse_Transaction(ds)
  print deserialize_Transaction(d)
  ds.close_file()
  blockfile.close()
Exemple #3
0
def _dump_tx(datadir, tx_hash, tx_pos):
  BLOCK_HEADER_SIZE = 80
  blockfile = open(os.path.join(datadir, "blocks","blk%05d.dat"%(tx_pos[0],)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, tx_pos[1]+BLOCK_HEADER_SIZE+tx_pos[2])
  tx = parse_Transaction(ds)
  tx['hash'] = tx_hash[::-1]
  ds.close_file()
  blockfile.close()
  return tx
Exemple #4
0
def _dump_tx(datadir, tx_hash, tx_pos):
    BLOCK_HEADER_SIZE = 80
    blockfile = open(
        os.path.join(datadir, "blocks", "blk%05d.dat" % (tx_pos[0], )), "rb")
    ds = BCDataStream()
    ds.map_file(blockfile, tx_pos[1] + BLOCK_HEADER_SIZE + tx_pos[2])
    tx = parse_Transaction(ds)
    tx['hash'] = tx_hash[::-1]
    ds.close_file()
    blockfile.close()
    return tx
Exemple #5
0
def _dump_block(datadir, nFile, nBlockPos, blkhash):
  blockfile = open(os.path.join(datadir,"blocks","blk%05d.dat"%(nFile,)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, nBlockPos)
  block_start = ds.read_cursor
  block = parse_Block(ds)
  block_end = ds.read_cursor
  block['blk_size'] = (block_end - block_start)
  ds.close_file()
  blockfile.close()
  return block
Exemple #6
0
def _dump_block(datadir, nFile, nBlockPos, blkhash):
    blockfile = open(
        os.path.join(datadir, "blocks", "blk%05d.dat" % (nFile, )), "rb")
    ds = BCDataStream()
    ds.map_file(blockfile, nBlockPos)
    block_start = ds.read_cursor
    block = parse_Block(ds)
    block_end = ds.read_cursor
    block['blk_size'] = (block_end - block_start)
    ds.close_file()
    blockfile.close()
    return block
Exemple #7
0
def _dump_block(datadir, nFile, nBlockPos, hash256, hashNext, do_print=True):
    blockfile = open(os.path.join(datadir, "blk%04d.dat" % (nFile,)), "rb")
    ds = BCDataStream()
    ds.map_file(blockfile, nBlockPos)
    d = parse_Block(ds)
    block_string = deserialize_Block(d)
    ds.close_file()
    blockfile.close()
    if do_print:
        print "BLOCK " + long_hex(hash256[::-1])
        print "Next block: " + long_hex(hashNext[::-1])
        print block_string
    return block_string
Exemple #8
0
def _dump_block(datadir, nFile, nBlockPos, hash256, hashNext, do_print=True):
    blockfile = open(os.path.join(datadir, "blk%04d.dat" % (nFile, )), "rb")
    ds = BCDataStream()
    ds.map_file(blockfile, nBlockPos)
    d = parse_Block(ds)
    block_string = deserialize_Block(d)
    ds.close_file()
    blockfile.close()
    if do_print:
        print "BLOCK " + long_hex(hash256[::-1])
        print "Next block: " + long_hex(hashNext[::-1])
        print block_string
    return block_string
Exemple #9
0
def _dump_block(datadir,
                nFile,
                nBlockPos,
                hash256,
                hashNext,
                do_print=True,
                print_raw_tx=False,
                print_json=False):
    blockfile = open(os.path.join(datadir, "blk%04d.dat" % (nFile, )), "rb")
    ds = BCDataStream()
    ds.map_file(blockfile, nBlockPos)
    d = parse_Block(ds)
    block_string = deserialize_Block(d, print_raw_tx)
    ds.close_file()
    blockfile.close()
    if do_print:
        print "BLOCK " + long_hex(hash256[::-1])
        print "Next block: " + long_hex(hashNext[::-1])
        print block_string
    elif print_json:
        import json
        print json.dumps({
            'version':
            d['version'],
            'previousblockhash':
            d['hashPrev'][::-1].encode('hex'),
            'transactions':
            [tx_hex['__data__'].encode('hex') for tx_hex in d['transactions']],
            'time':
            d['nTime'],
            'bits':
            hex(d['nBits']).lstrip("0x"),
            'nonce':
            d['nNonce']
        })

    return block_string
Exemple #10
0
def _dump_block(datadir, nFile, nBlockPos, hash256, hashNext, do_print=True, print_raw_tx=False, print_json=False):
  blockfile = open(os.path.join(datadir, "blk%04d.dat"%(nFile,)), "rb")
  ds = BCDataStream()
  ds.map_file(blockfile, nBlockPos)
  d = parse_Block(ds)
  block_string = deserialize_Block(d, print_raw_tx)
  ds.close_file()
  blockfile.close()
  if do_print:
    print "BLOCK "+long_hex(hash256[::-1])
    print "Next block: "+long_hex(hashNext[::-1])
    print block_string
  elif print_json:
    import json
    print json.dumps({
                        'version': d['version'],
                        'previousblockhash': d['hashPrev'][::-1].encode('hex'),
                        'transactions' : [ tx_hex['__data__'].encode('hex') for tx_hex in d['transactions'] ],
                        'time' : d['nTime'],
                        'bits' : hex(d['nBits']).lstrip("0x"),
                        'nonce' : d['nNonce']
                      })

  return block_string
Exemple #11
0
 def dumpblock(self, block_position, block_time, opened_file):
     ds = BCDataStream()
     ds.map_file(opened_file, block_position)
     d = parse_Block(ds)
     deserialize_Block(d, block_time, self.addresses)
     ds.close_file()
Exemple #12
0
 def dumpblock(self,block_position, block_time, opened_file):
     ds = BCDataStream()
     ds.map_file(opened_file, block_position)
     d = parse_Block(ds)
     deserialize_Block(d, block_time, self.addresses)
     ds.close_file()