Пример #1
0
def home():
    node_info = stub.GetInfo(ln.GetInfoRequest())
    node_info_detail = stub.GetNodeInfo(ln.NodeInfoRequest(pub_key=node_info.identity_pubkey))

    content = {
        'identity_pubkey': node_info.identity_pubkey,
        'uris': node_info.uris,
        'alias': node_info.alias,
        'chains': node_info.chains,
        'version': node_info.version,
        'block_height': node_info.block_height,
        'synced': str(node_info.synced_to_chain),
        'block_hash': node_info.block_hash,
        'num_active_channels': node_info.num_active_channels,
        'num_inactive_channels': node_info.num_inactive_channels,
        'num_pending_channels': node_info.num_pending_channels,
        'num_peers': node_info.num_peers,
        'total_capacity': node_info_detail.total_capacity
    }

    return render_template('index.html', **content)
Пример #2
0
def home():
    node_info = stub.GetInfo(ln.GetInfoRequest())
    node_info_detail = stub.GetNodeInfo(
        ln.NodeInfoRequest(pub_key=node_info.identity_pubkey))

    content = {
        "identity_pubkey": node_info.identity_pubkey,
        "uris": node_info.uris,
        "alias": node_info.alias,
        "chains": node_info.chains,
        "version": node_info.version,
        "block_height": node_info.block_height,
        "synced": str(node_info.synced_to_chain),
        "block_hash": node_info.block_hash,
        "num_active_channels": node_info.num_active_channels,
        "num_inactive_channels": node_info.num_inactive_channels,
        "num_pending_channels": node_info.num_pending_channels,
        "num_peers": node_info.num_peers,
        "total_capacity": node_info_detail.total_capacity,
    }

    return render_template("index.html", **content)
Пример #3
0
def query():
    nodes = stub.DescribeGraph(ln.ChannelGraphRequest()).nodes

    content = {"nodes": nodes, "node_count": len(nodes), "routes": []}

    if request.method == "POST":
        map_data = {"edges": [], "nodes": []}

        # Add Local Node to map data
        local_node = stub.GetInfo(ln.GetInfoRequest())
        local_node_info = stub.GetNodeInfo(
            ln.NodeInfoRequest(pub_key=local_node.identity_pubkey))
        map_data["nodes"].append({
            "id": local_node_info.node.pub_key,
            "label": local_node_info.node.alias,
            "color": local_node_info.node.color,
        })

        routes_list = stub.QueryRoutes(
            ln.QueryRoutesRequest(
                pub_key=request.form["node-result"],
                amt=int(request.form["amount"]),
                num_routes=10,
            )).routes

        for route in routes_list:
            hops = []

            for hop in route.hops:
                node_info = stub.GetNodeInfo(
                    ln.NodeInfoRequest(pub_key=hop.pub_key))
                chan_info = stub.GetChanInfo(
                    ln.ChanInfoRequest(chan_id=hop.chan_id))

                node = {
                    "id": node_info.node.pub_key,
                    "label": node_info.node.alias,
                    "color": node_info.node.color,
                }
                if hop.pub_key == chan_info.node1_pub:
                    edge = {
                        "from": chan_info.node2_pub,
                        "to": chan_info.node1_pub,
                        "label": chan_info.channel_id,
                        "arrows": "to",
                        "font": "{align: 'middle'}",
                    }
                else:
                    edge = {
                        "from": chan_info.node1_pub,
                        "to": chan_info.node2_pub,
                        "label": chan_info.channel_id,
                        "arrows": "to",
                        "font": "{align: 'middle'}",
                    }

                if node not in map_data["nodes"]:
                    map_data["nodes"].append(node)
                if edge not in map_data["edges"]:
                    map_data["edges"].append(edge)

                hops.append({
                    "chan_id": hop.chan_id,
                    "chan_capacity": hop.chan_capacity,
                    "amt_to_forward": hop.amt_to_forward_msat / 1000,
                    "fee": hop.fee_msat / 1000,
                    "pub_key": hop.pub_key,
                    "node_alias": node_info.node.alias,
                    "node_color": node_info.node.color,
                })

            content["routes"].append({
                "hops":
                hops,
                "total_amt":
                route.total_amt_msat / 1000,
                "total_fees":
                route.total_fees_msat / 1000,
            })

        content.update({"map_data": json.dumps(map_data)})

        return render_template("query-success.html", **content)

    return render_template("query.html", **content)
Пример #4
0
macaroon = open(config.macaroon_path, "rb").read().hex()
cert = open(config.cert_path, "rb").read()
cert_creds = grpc.ssl_channel_credentials(cert)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
combined_creds = grpc.composite_channel_credentials(cert_creds, auth_creds)
grpc_options = [
    ("grpc.max_receive_message_length", config.grpc_max_length),
    ("grpc.max_send_message_length", config.grpc_max_length),
]
channel = grpc.secure_channel(
    config.lnd_grpc_server, combined_creds, options=grpc_options
)
stub = lnrpc.LightningStub(channel)


node_info = stub.GetInfo(ln.GetInfoRequest())
node_info_detail = stub.GetNodeInfo(
        ln.NodeInfoRequest(pub_key=node_info.identity_pubkey)
    )
node_pub_key = node_info_detail.node.pub_key
def getAlias(ChanInfo):
    if ChanInfo.node1_pub == node_pub_key:
        node_pub =  ChanInfo.node2_pub
    else:
        node_pub =  ChanInfo.node1_pub

    node_info = stub.GetNodeInfo(
            ln.NodeInfoRequest(pub_key=node_pub))
    alias = node_info.node.alias
    return alias,ChanInfo.channel_id