Exemplo n.º 1
0
def setup_house(request):
    """Setup different networks supported by the instance.

    Setup house wallets on each network.

    Setup ETH giveaway on testnet and private testnet.
    """

    dbsession = request.dbsession

    services = ServiceCore.parse_network_config(request)
    networks = services.keys()

    for network_name in networks:

        print("Setting up house wallet on ", network_name)

        network = get_eth_network(dbsession, network_name)
        assert is_network_alive(network), "Network was dead when we started to create address {}".format(network)

        dbsession.flush()
        house_address = get_house_address(network)

        if not house_address:
            create_house_address(network)

        if not "initial_assets" in network.other_data:
            network.other_data["initial_assets"] = {}

        if network_name == "testnet":
            network.other_data["human_friendly_name"] = "Ethereum Testnet"

        # Setup testnet ETH give away
        if network_name in ("testnet", "private testnet"):
            network.other_data["initial_assets"]["eth_amount"] = "5.0"
Exemplo n.º 2
0
def setup_house(request):
    """Setup different networks supported by the instance.

    Setup house wallets on each network.

    Setup ETH giveaway on testnet and private testnet.
    """

    dbsession = request.dbsession

    services = ServiceCore.parse_network_config(request)
    networks = services.keys()

    for network_name in networks:

        print("Setting up house wallet on ", network_name)

        network = get_eth_network(dbsession, network_name)
        assert is_network_alive(network), "Network was dead when we started to create address {}".format(network)

        dbsession.flush()
        house_address = get_house_address(network)

        if not house_address:
            create_house_address(network)

        if not "initial_assets" in network.other_data:
            network.other_data["initial_assets"] = {}

        if network_name == "testnet":
            network.other_data["human_friendly_name"] = "Ethereum Testnet"

        # Setup testnet ETH give away
        if network_name in ("testnet", "private testnet"):
            network.other_data["initial_assets"]["eth_amount"] = "5.0"
Exemplo n.º 3
0
def house_address(dbsession, eth_service, web3, eth_network_id) -> UUID:
    """Create a network specific house address.

    :return: Address UUID
    """
    with transaction.manager:
        network = dbsession.query(AssetNetwork).get(eth_network_id)
        op = create_house_address(network)
        opid = op.id
        address_id = op.address.id
        assert address_id

    # this runs op
    eth_service.run_waiting_operations()

    with transaction.manager:
        address = dbsession.query(CryptoAddress).get(address_id)
        addr = bin_to_eth_address(address.address)

    # Send some funds to the house from coinbase
    txid = send_balance_to_address(web3, addr, Decimal("0.1"))
    wait_tx(web3, txid)

    return address_id
Exemplo n.º 4
0
def house_address(dbsession, eth_service, web3, eth_network_id) -> UUID:
    """Create a network specific house address.

    :return: Address UUID
    """
    with transaction.manager:
        network = dbsession.query(AssetNetwork).get(eth_network_id)
        op = create_house_address(network)
        opid = op.id
        address_id = op.address.id
        assert address_id

    # this runs op
    eth_service.run_waiting_operations()

    with transaction.manager:
        address = dbsession.query(CryptoAddress).get(address_id)
        addr = bin_to_eth_address(address.address)

    # Send some funds to the house from coinbase
    txid = send_balance_to_address(web3, addr, Decimal("0.1"))
    wait_tx(web3, txid)

    return address_id