コード例 #1
0
ファイル: block_test.py プロジェクト: zhangchi1992/py-bitcoin
def test_genesis_block():
    coinbase = new_coinbase_tx("7AgP8z7XYyZ2sdnVJ6HCiE5X2reJDf")

    genesis_block = new_genesis_block(coinbase)
    print(genesis_block)

    # we will get the genesis block like this, but there many work need to do, just
    '''
コード例 #2
0
ファイル: blockchain_test.py プロジェクト: yqxorg/py-bitcoin
def test_create_bc():
    bc = BlockChain()

    # 创世区块
    coinbase = new_coinbase_tx("7AgP8z7XYyZ2sdnVJ6HCiE5X2reJDf")
    genesis_block = new_genesis_block(coinbase)
    bc.add_block(genesis_block)

    b = Block()
    # 自定义几个block
    for i in range(5):
        transactions = [b'Node1', b"Node2", b"Node3", b"Node4"]
        last_hash = bc.blocks.get("l").decode()
        height = bc.get_height()
        new_block = b.new_block(transactions, last_hash, height + 1)
        bc.add_block(new_block)
コード例 #3
0
def build_coinbase_tx(to, data=None):
    tx = new_coinbase_tx(to, data) if data else new_coinbase_tx(to)
    return tx
コード例 #4
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
This Document is Created by  At 2018/7/10 
"""

from core.transactions.transaction import Transaction, new_coinbase_tx

if __name__ == '__main__':
    to = "1KX2LcZeMf4v4JB5KNFD6HKjzckj4n1BhE"

    tx = new_coinbase_tx(to)

    print(tx.serialize())