def create_block_for_submission(block):
    submission_block = ""

    submission_block += util.bin2hex(make_header_from_template(block))
    submission_block += util.int2varinthex(len(block['transactions']))
    for tx in block['transactions']:
        submission_block += tx['data']

    return submission_block
def block_make_submit(block):
    subm = ""

    # Block header
    subm += util.bin2hex(block_form_header(block))
    # Number of transactions as a varint
    subm += util.int2varinthex(len(block['transactions']))
    # Concatenated transactions data
    for tx in block['transactions']:
        subm += tx['data']

    return subm
def tx_make_coinbase(coinbase_script, address, value):

    # Create a pubkey script
    # OP_DUP OP_HASH160 <len to push> <pubkey> OP_EQUALVERIFY OP_CHECKSIG
    pubkey_script = "76" + "a9" + "14" + util.bitcoinaddress2hash160(
        address) + "88" + "ac"

    tx = ""
    tx += "01000000"
    tx += "01"
    tx += "0" * 64
    tx += "ffffffff"
    tx += util.int2varinthex(len(coinbase_script) / 2)
    tx += coinbase_script
    tx += "ffffffff"
    tx += "01"
    tx += util.int2lehex(value, 8)
    tx += util.int2varinthex(len(pubkey_script) / 2)
    tx += pubkey_script
    tx += "00000000"

    return tx
def tx_make_coinbase(coinbase_script, address, value):
    '''
    The following coinbase has to be made exactly as per the guideline from the bitcoin team.
    '''
    # Create a pubkey script
    # OP_DUP OP_HASH160 <len to push> <pubkey> OP_EQUALVERIFY OP_CHECKSIG
    pubkey_script = "76" + "a9" + "14" + util.bitcoinaddress2hash160(address) + "88" + "ac"

    tx = ""
    tx += "01000000"
    tx += "01"
    tx += "0"*64
    tx += "ffffffff"
    tx += util.int2varinthex(len(coinbase_script)/2)
    tx += coinbase_script
    tx += "ffffffff"
    tx += "01"
    tx += util.int2lehex(value, 8)
    tx += util.int2varinthex(len(pubkey_script)/2)
    tx += pubkey_script
    tx += "00000000"

    return tx