Beispiel #1
0
def address_info(address):
    data = Address.history(address)

    if data["error"] is None:
        result = data["result"]
        mempool = Address.mempool(address)["result"]
        balance = Address.balance(address)["result"]

        # ToDo: Fix outputs count here

        return {
            "address": address,
            "chain_stats": {
                "funded_txo_count": 0,
                "funded_txo_sum": balance["received"],
                "spent_txo_count": 0,
                "spent_txo_sum": balance["received"] - balance["balance"],
                "tx_count": result["txcount"]
            },
            "mempool_stats": {
                "funded_txo_count": 0,
                "funded_txo_sum": 0,
                "spent_txo_count": 0,
                "spent_txo_sum": 0,
                "tx_count": mempool["txcount"]
            }
        }

    else:
        return Response("Invalid Bitcoin address",
                        mimetype="text/plain",
                        status=400)
Beispiel #2
0
def address_history(address):
    offset = request.args.get("offset")
    limit = request.args.get("limit")

    offset = int(0 if offset is None else offset)
    limit = int(10 if limit is None else limit)

    if limit > 200:
        limit = 200

    data = Address.history(address)
    if data["error"] is None:
        data["result"]["tx"] = data["result"]["tx"][offset:offset + limit]

    return jsonify(data)
Beispiel #3
0
def address_transactions(address, thash):
    data = Address.history(address)
    transactions = []
    start = 0

    if data["error"] is None:
        result = data["result"]

        if thash in result["tx"]:
            start = result["tx"].index(thash) + 1

        for thash in result["tx"][start:start + config.tx_page]:
            transaction = Transaction.info(thash)["result"]
            transactions.append(Esplora().transaction(transaction))

        return jsonify(transactions)

    else:
        return Response("Invalid Bitcoin address",
                        mimetype="text/plain",
                        status=400)
Beispiel #4
0
def AddressHistory(address=None):
    return Address.history(address)