def submit_block_with_tx(node, tx):
    ctx = CTransaction()
    ctx.deserialize(io.BytesIO(hex_str_to_bytes(tx)))
    tip = node.getbestblockhash()
    height = (node.getblockcount() + 1)
    block_time = (node.getblockheader(tip)['mediantime'] + 1)
    block = blocktools.create_block(int(tip, 16), blocktools.create_coinbase(height), block_time)
    block.vtx.append(ctx)
    block.rehash()
    block.hashMerkleRoot = block.calc_merkle_root()
    block.solve()
    error = node.submitblock(bytes_to_hex_str(block.serialize(True)))
    if (error is not None):
        raise Exception(error)
    return block
def submit_block_with_tx(node, tx):
    ctx = CTransaction()
    ctx.deserialize(io.BytesIO(hex_str_to_bytes(tx)))
    tip = node.getbestblockhash()
    height = (node.getblockcount() + 1)
    block_time = (node.getblockheader(tip)['mediantime'] + 1)
    block = blocktools.create_block(int(tip, 16), blocktools.create_coinbase(height), block_time)
    block.vtx.append(ctx)
    block.rehash()
    block.hashMerkleRoot = block.calc_merkle_root()
    block.solve()
    error = node.submitblock(bytes_to_hex_str(block.serialize(True)))
    if (error is not None):
        raise Exception(error)
    return block