Welcome to the documentation of the ln-history project. In this guide we will build the infrastructure to persist gossip messages of the Bitcoin Lightning network. I tried to make this setup process as simple as possible. If you struggle at some point or find an error, feel free to create an Github Issue here.
Depending on your preferences, ln-history can be used in three different modes:
| Mode | Description | Difficulty |
|---|---|---|
| Direct Request | Request the ln-history infrastructure and parse results locally | very easy |
| Bring Your Own Data | Bulk insert your self collected gossip messages into the database once | easy |
| Real Time | Insert your collected gossip messages in real time into the database | harder |
The following diagram shows you which steps you need to fulfill to setup the infrastructure. The platform supports running bulk-import and real-time simultaneously.
I recommend the easiest mode for starters to familiarize yourself, see direct_request. Here you can play around with gossip messages from the ln-history plaform that I have collected, like creating snapshots etc.
The Bring Your Own Data and Real Time mode should run on a server and utilize docker compose. The latter will also need a running Bitcoin Core node as well as Core Lightning node(s). I have tested the real-time mode with an static ipv4 address attached to the Core Lightning node.
After finishing the setup you will be provided with endpoints:
node_id for a given timestampscid for a given timestampNote that the format of the results is raw bytes. They need to get parsed by a client. The lnhistoryclient is a python package that provides classes, functions and interfaces to easly parse the gossip (in raw bytes) results into more readable formats, featuring JSON and python networkx.
When deploying the real-time mode you can also get live gossip analysis, see for example here
Here you can see an visualization of the architecture
You can still use this tool and do it yourself.
Dr. Christian Decker collected and uploaded gossip messages ranging between 01-2018 to 09-2023.
See this repository, which provides links to his gossip messages.
You can download this data for free.
With ln-history I provide the infrastructure to analyze the gossip messages. Maybe this is all you are looking for?
The infrastructure relies on docker (and docker compose) trying to make it as platform independent as possible. Nonetheless, I highly recommend running it on a Linux machine (specifically Ubuntu), as that is the only environment I tested it on.
We follow the official documentation.
Setup up Docker's apt repository
Install the (latest) Docker packages
Verify that the installation is successful by running the hello-world image and check if you should see this result:
Hello from Docker! This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash
We follow the official documentation
We download and install the Docker Compose standalone
We apply executable permissions to the standalone binary in the target path for the installation
On your machine navigate to your desired location where the project will live. You might want to create a specific user for that.
You can then add this user to the sudo group if needed:
Switch to the new user:
We will now create the project root folder ln-history where all the services will be created in.
First setup the ln-history Core which consists of the database and the Backend. After that continue with Bring Your Own Data or Real Time depending on which mode you want to use.
In case you want to learn about the structure and format of Lightning Network gossip messages, please check out the gossip page.