diff --git a/backend/src/api/explorer/channels.api.ts b/backend/src/api/explorer/channels.api.ts index f0d7dc56b..79aeebb97 100644 --- a/backend/src/api/explorer/channels.api.ts +++ b/backend/src/api/explorer/channels.api.ts @@ -13,9 +13,10 @@ class ChannelsApi { } } - public async $getAllChannelsGeo(): Promise { + public async $getAllChannelsGeo(publicKey?: string): Promise { try { - const query = `SELECT nodes_1.public_key as node1_public_key, nodes_1.alias AS node1_alias, + const params: string[] = []; + let query = `SELECT nodes_1.public_key as node1_public_key, nodes_1.alias AS node1_alias, nodes_1.latitude AS node1_latitude, nodes_1.longitude AS node1_longitude, nodes_2.public_key as node2_public_key, nodes_2.alias AS node2_alias, nodes_2.latitude AS node2_latitude, nodes_2.longitude AS node2_longitude, @@ -26,7 +27,14 @@ class ChannelsApi { WHERE nodes_1.latitude IS NOT NULL AND nodes_1.longitude IS NOT NULL AND nodes_2.latitude IS NOT NULL AND nodes_2.longitude IS NOT NULL `; - const [rows]: any = await DB.query(query); + + if (publicKey !== undefined) { + query += ' AND (nodes_1.public_key = ? OR nodes_2.public_key = ?)'; + params.push(publicKey); + params.push(publicKey); + } + + const [rows]: any = await DB.query(query, params); return rows.map((row) => [ row.node1_public_key, row.node1_alias, row.node1_longitude, row.node1_latitude, row.node2_public_key, row.node2_alias, row.node2_longitude, row.node2_latitude, diff --git a/backend/src/api/explorer/channels.routes.ts b/backend/src/api/explorer/channels.routes.ts index c6df30802..495eec789 100644 --- a/backend/src/api/explorer/channels.routes.ts +++ b/backend/src/api/explorer/channels.routes.ts @@ -11,7 +11,8 @@ class ChannelsRoutes { .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels/search/:search', this.$searchChannelsById) .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels/:short_id', this.$getChannel) .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels', this.$getChannelsForNode) - .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels-geo', this.$getChannelsGeo) + .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels-geo', this.$getAllChannelsGeo) + .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels-geo/:publicKey', this.$getAllChannelsGeo) ; } @@ -94,9 +95,9 @@ class ChannelsRoutes { } } - private async $getChannelsGeo(req: Request, res: Response) { + private async $getAllChannelsGeo(req: Request, res: Response) { try { - const channels = await channelsApi.$getAllChannelsGeo(); + const channels = await channelsApi.$getAllChannelsGeo(req.params?.publicKey); res.json(channels); } catch (e) { res.status(500).send(e instanceof Error ? e.message : e); diff --git a/frontend/src/app/lightning/channels-list/channels-list.component.html b/frontend/src/app/lightning/channels-list/channels-list.component.html index a6d553ef1..ff67788e1 100644 --- a/frontend/src/app/lightning/channels-list/channels-list.component.html +++ b/frontend/src/app/lightning/channels-list/channels-list.component.html @@ -1,6 +1,4 @@
-

Channels ({{ response.totalItems }})

-