예제 #1
0
def get_balance_network_usd(request, network, usd_price):
    wallet = Wallet(request.user.wallet_id)
    balance_in_satoshi = wallet.balance(network=network)
    balance_in_bitcoin = balance_in_satoshi / 1000000
    price_in_usd = float(balance_in_bitcoin) * float(usd_price)
    return {
        "priceUSD": price_in_usd,
        "balanceBTC": print_value(balance_in_bitcoin, network=network.lower())
    }
예제 #2
0
def total_balance(request, infos):
    wallet = Wallet(request.user.wallet_id)
    networks = NetworkDefinition.objects.all()
    balance = 0
    for info in infos:
        for network in networks:
            if info["symbol"] == network.symbol:
                balance += float(info["priceUsd"]) * float(
                    wallet.balance(network=network.network))
    return balance
예제 #3
0
def get_networks_info(request, networks):
    network_infos = []
    wallet = Wallet(request.user.wallet_id)
    for network in networks:
        network_info.append({
            "network":
            network["network"],
            "balance":
            wallet.balance(network=network["network"])
        })
    return network_infos