Skip to main content

A reusable parser for Lightning Network gossip messages format.

Project description

โšก ln-history-python-client

A Python client library to parse and handle raw Lightning Network gossip messages from the gossip store. Centralized, reusable, and production-tested on real-world data. Perfect for microservices that consume Lightning Network data in raw_hex format.


๐Ÿ“ฆ Features

  • ๐Ÿ” Parses raw gossip messages: Channel Announcements, Channel Updates, Node Announcements, and more
  • ๐Ÿงฑ Clean and extensible object model (e.g., ChannelAnnouncement, NodeAnnouncement, ChannelUpdate)
  • ๐Ÿงช Tested on real-world data
  • ๐Ÿงฐ Built with reusability in mind for microservice architectures

๐Ÿ› ๏ธ Installation

pip install 

๐Ÿงฌ Usage

from lnhistoryclient.parser import parser_factory

raw_hex = "0101..."  # Replace with actual raw gossip hex string
parsed = parser_factory.parse(raw_hex)

print(parsed)

You can also directly use individual parsers if you know the message type:

from lnhistoryclient.parser.channel_announcement_parser import parse_channel_announcement

result = parse_channel_announcement(raw_hex)
print(result.channel_id, result.node1_id, result.node2_id)

๐Ÿ“ Project Structure

lnhistoryclient
โ”œโ”€โ”€ model
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ Address.py
โ”‚   โ”œโ”€โ”€ AddressType.py
โ”‚   โ”œโ”€โ”€ ChannelAnnouncement.py
โ”‚   โ”œโ”€โ”€ ChannelUpdate.py
โ”‚   โ”œโ”€โ”€ core-lightning-internal
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ ChannelAmount.py
โ”‚   โ”‚   โ”œโ”€โ”€ ChannelDying.py
โ”‚   โ”‚   โ”œโ”€โ”€ DeleteChannel.py
โ”‚   โ”‚   โ”œโ”€โ”€ GossipStoreEnded.py
โ”‚   โ”‚   โ”œโ”€โ”€ PrivateChannelAnnouncement.py
โ”‚   โ”‚   โ””โ”€โ”€ PrivateChannelUpdate.py
โ”‚   โ””โ”€โ”€ NodeAnnouncement.py
โ””โ”€โ”€ parser
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ channel_announcement_parser.py
    โ”œโ”€โ”€ channel_update_parser.py
    โ”œโ”€โ”€ common.py
    โ”œโ”€โ”€ core-lightning-internal
    โ”‚   โ”œโ”€โ”€ channel_amount_parser.py
    โ”‚   โ”œโ”€โ”€ channel_dying_parser.py
    โ”‚   โ”œโ”€โ”€ delete_channel_parser.py
    โ”‚   โ”œโ”€โ”€ gossip_store_ended_parser.py
    โ”‚   โ”œโ”€โ”€ private_channel_announcement_parser.py
    โ”‚   โ””โ”€โ”€ private_channel_update_parser.py
    โ”œโ”€โ”€ node_announcement_parser.py
    โ””โ”€โ”€ parser_factory.py

๐Ÿงช Testing

Unit tests coming soon.

๐Ÿง  Requirements

Python >=3.7, <4.0 Pure Python, no external dependencies

๐Ÿค Contributing

Pull requests, issues, and feature ideas are always welcome! Fork the repo Create a new branch Submit a PR with a clear description

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lnhistoryclient-1.2.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lnhistoryclient-1.2.1-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file lnhistoryclient-1.2.1.tar.gz.

File metadata

  • Download URL: lnhistoryclient-1.2.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lnhistoryclient-1.2.1.tar.gz
Algorithm Hash digest
SHA256 833f1cfd38e97017583e600f67db8d98d49f00c77c3942a44a8326732ef6fbc2
MD5 a86c9cfa3059b852558c1eb52b6af05c
BLAKE2b-256 d15f3ef3daa92b3a3a216b715b4cd45c4e3c9f6c43dd14e6cbee9e6eb7422524

See more details on using hashes here.

Provenance

The following attestation bundles were made for lnhistoryclient-1.2.1.tar.gz:

Publisher: release.yml on ln-history/ln-history-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lnhistoryclient-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for lnhistoryclient-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 302a16d833df1e6a7eb85e5a0a81c9ed8a592af2e0b11deaaf0a6c30dfd658e8
MD5 8b456e349225a8d966eb24402679ea15
BLAKE2b-256 c9d16cbcc42237b0e8bbd430988cbdd6757156f6073ca73621fb677fbb7d2eb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lnhistoryclient-1.2.1-py3-none-any.whl:

Publisher: release.yml on ln-history/ln-history-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page