Building a Lightning Network explorer

Vinayak Sharma
4 min readAug 18, 2022

Project Idea

Why is a lightning Network explorer required?

A lightning network explorer makes it easier for lightning network users to trace their LN transactions. The aim of this project is to be build a LN explorer that links the lightning network transactions onto the bitcoin blockchain. This helps the user know exactly about the location of the transaction.

Integration of lightning Network explorer with Esplora

Esplora is a bitcoin blockchain explorer in it’s current state. The aim of this project is to add the information about the various different components of a lightning network to the Esplora project. This will help the users in finding detailed information about a channel and it’s funding and closing transactions. The channel profile will also provide the user with a detailed timeline like view of the channel (Basically providing the history of a channel for better analysis). The user can also checkout various different information about a node. The node profile also includes information about the channels that it is connected to. The main aim for integrating a lightning network explorer on Esplora is to enable the link between the on chain bitcoin blockchain and the 2nd layer — lightning network.

Features implemented

Creating a node.js server for reading raw gossip messages

The first step in this project was to create a node server that will fetch raw gossip messages from a SQLite based database and parse them into meaningful information that can be later used for creating the frontend of this project.

Stepwise approach for parsing raw gossip messaegs

Node server’s GitHub repo — https://github.com/vinayaksh42/clightning-node-server

The above node server provides the following endpoints:

General endpoints —

1. /channel_list - provides a list of the latest channels in "channel_announcement" table (mainly used for displaying channels on LN explorer tab)2. /node_list - provides a list of the latest nodes in "node_announcement" table (mainly used for displaying channels on LN explorer tab)

Id specific endpoints —

1. /channel_profile/:scid - provides the channel profile for a particular channel. the channel profile includes the following info about a channel:{"scid":"812404952712347648","amount_sat":4567,"closing_height":"748412","block":"738878","tx_id":"3120","output_index":"0","node_id_1":"023fca3d779d3def8e99cfae86fb37b10b04c2f63324fe45aeece536eadce10947","node_id_2":"038fe1bd966b5cb0545963490c631eaa1924e2c4c0ea4e7dcb5d4582a1e7f2f1a5","txid":"02a76081cde11bf7209c2ee056f3eccb718cedab1c1a8c387575fbf18c0bf94c","closing":"760f1ffca8dc5cc065b5ec5a2207160eb46ea4b643c95072fefafae48983d3d7"}
- short channel id
- amount_sat
- block
- transaction id
- output index
- full transaction id (funding)
- closing transaction
- closing block height
- node id 1
- node id 2
2. /channel_updates/:scid - provides the channels updates for queried short channel id.3. /node_profile/:nodeid - provides the node profile for a particular node. The node profile includes the following info about a node:{"node_id":"038fe1bd966b5cb0545963490c631eaa1924e2c4c0ea4e7dcb5d4582a1e7f2f1a5","scid":["812404952712347648","812404952711430145","812404952713134081","812412649192030209","812412649192095745","812412649161293825","812411549713694721"],"rgb_color":"1c262f"}
- node id
- short channel id for all the connected channels
- rgb color

Cron job is used for updating the channel_profile table after every hour.

Adding info about Lightning network to Esplora

The three main pages added to Esplora are:

  1. LN explorer tab
  2. Channel profile
  3. Node profile

LN explorer tab

The LN explorer tab has a list of latest channels and node. In future this can be changed to something interesting such as channels with the most number of channel updates or nodes with most number of channels.

latest channels

latest nodes

Channel Profile

Channel profile is the most important page in terms of information about the lightning network transaction as it contains information funding and closing transaction.

The initial channel profile page contains information such as:

  • short channel id
  • amount sat
  • block height
  • transaction id
  • output index
  • node id 1
  • node id 2
  • funding transaction id

The above part of the channel profile contains information about the funding transaction and closing transaction as well as it’s closing block height.

Channel profile also contains the channel updates which provides a timeline like view of the channel history. It can help users in understanding more about their channels and figuring out “what went wrong with the channel” in case of a failure.

Node profile

The node profile contains all the essential information about a node. The node profile enables the user to navigate from a node profile to all the channels that are connected to that node

The node profile includes the following information:

  • node id
  • rgb color
  • short channel id of the connected channels
  • connection information

Future idea

This implementation of lightning network explorer is fairly straightforward and checks all the boxes for helping a user navigate the lightning network effortlessly

Following features can be added to the project:

  • show casing the channel updates in a graph manner
  • optimizing the speed for populating channel_profile table
  • integrating the lightning network component search within the esplora search bar

--

--