コード例 #1
0
def reorganize(ec, fork_point, arr, repl):
    print 'Reorganize!', ec, fork_point
    a.bdb_chain.subscribe_reorganize(reorganize)
    for blk in arr:
        print 'arrive', b.hash_block_header(blk)
    for blk in repl:
        print 'remove', b.hash_block_header(blk)
コード例 #2
0
def display_chain(chain):
    previous = None
    for i, blk in enumerate(chain):
        if previous is not None:
            assert str(blk.previous_block_hash) == str(previous)
        previous = bitcoin.hash_block_header(blk)
        print 'Block:', i
        print bitcoin.hash_block_header(blk)
コード例 #3
0
ファイル: composed.py プロジェクト: Ramblurr/electrum-server
 def block_header(self, ec, blk_head, statement_line, info):
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     self.chain.fetch_transaction(tx_hash,
         bitcoin.bind(self.load_tx, bitcoin._1, bitcoin._2,
             statement_line, info))
コード例 #4
0
ファイル: qtable.py プロジェクト: genjix/qlayer
 def examine_blk(self, depth, blk):
     self._latest_block_hash = bitcoin.hash_block_header(blk)
     for tx in blk.transactions:
         self._check(tx, True)
     self._cursor.execute("""
         INSERT INTO blocks (depth, hash)
         VALUES (%s, %s)
     """, (depth, self._latest_block_hash))
コード例 #5
0
 def block_header(self, ec, blk_head, entry, info):
     if self.stop_on_error(ec):
         return
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     # Now load the actual main transaction for this input or output
     self.chain.fetch_transaction(tx_hash, bind(self.load_chain_tx, _1, _2, entry, info))
コード例 #6
0
ファイル: composed.py プロジェクト: bwrega/ltclectrum-server
 def block_header(self, ec, blk_head, statement_line, info):
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     self.chain.fetch_transaction(
         tx_hash,
         bitcoin.bind(self.load_tx, bitcoin._1, bitcoin._2, statement_line,
                      info))
コード例 #7
0
ファイル: qtable.py プロジェクト: genjix/qlayer
 def examine_blk(self, depth, blk):
     self._latest_block_hash = bitcoin.hash_block_header(blk)
     for tx in blk.transactions:
         self._check(tx, True)
     self._cursor.execute(
         """
         INSERT INTO blocks (depth, hash)
         VALUES (%s, %s)
     """, (depth, self._latest_block_hash))
コード例 #8
0
def display_block_header(ec, blk):
    if ec:
        print "Failure fetching block header:", ec.message()
        sys.exit()
    blk_hash = hash_block_header(blk)
    print "hash:", blk_hash.encode('hex')
    print "version:", blk.version
    print "previous_block_hash:", blk.previous_block_hash
    print "merkle:", blk.merkle
コード例 #9
0
ファイル: history.py プロジェクト: bwrega/ltclectrum-server
 def block_header(self, ec, blk_head, entry, info):
     if self.stop_on_error(ec):
         return
     info["timestamp"] = blk_head.timestamp
     info["block_hash"] = str(bitcoin.hash_block_header(blk_head))
     tx_hash = bitcoin.hash_digest(info["tx_hash"])
     # Now load the actual main transaction for this input or output
     self.chain.fetch_transaction(
         tx_hash, bind(self.load_chain_tx, _1, _2, entry, info))
コード例 #10
0
def create_get_blocks_message():
    packet = bitcoin.get_blocks()
    genesis_hash = bitcoin.hash_block_header(bitcoin.genesis_block())
    packet.start_hashes.append(genesis_hash)
    packet.hash_stop = bitcoin.null_hash
    return packet
コード例 #11
0
raw_tx_repr = "010000000187493c4c15c76df9f69ddd7aeb7ffbcddad4b7a979210f19602282d5b9862581000000008a47304402202d9e9f75be9c8a4c4304931b032e1de83fd2c6af2c1154a3d2b885efd5c3bfda02201184139215fb74499eae9c71ae86354c41b4d20b95a6b1fffcb8f1c5f051288101410497d11f5c33adb7c3fed0adc637358279de04f72851b7b93fb4a8655613729047c7e2908966551b5fb7f6899f6c3dd358b57eb20a61b2c9909aa106eac6310f9fffffffff0140420f00000000001976a91407e761706c63b36e5a328fab1d94e9397f40704d88b000000000"
raw_tx = bitcoin.data_chunk(raw_tx_repr)
print raw_tx
print len(raw_tx)

ex = bitcoin.satoshi_exporter()
tx = ex.load_transaction(raw_tx)
print "txhash", bitcoin.hash_transaction(tx)
print tx
print ex.save_transaction(tx)
print len(ex.save_transaction(tx))
assert str(ex.save_transaction(tx)) == raw_tx_repr

print 'blk'
blk = bitcoin.genesis_block()
print bitcoin.hash_block_header(blk)
rawblk = ex.save_block(blk)
blk2 = ex.load_block(rawblk)
print bitcoin.hash_block_header(blk2)
print bitcoin.hash_transaction(blk.transactions[0])
print bitcoin.hash_transaction(blk2.transactions[0])
assert str(ex.save_block(blk2)) == str(rawblk)

getblocks = bitcoin.get_blocks()
getblocks.start_hashes.append(bitcoin.hash_block_header(blk))
getblocks.start_hashes.append(bitcoin.hash_transaction(blk.transactions[0]))
getblocks.hash_stop = bitcoin.null_hash
rawgb = ex.save_get_blocks(getblocks)
gb2 = ex.load_get_blocks(rawgb)
print gb2.start_hashes[0]
print gb2.start_hashes[1]