Code Monkey home page Code Monkey logo

lseed's Introduction

lseed -- A Lightning DNS Seed

Upon first joining the Lightning Network, a node must open a few connections to existing nodes in the network. However, it can only learn of nodes that are present in the network through its peers. This Seed helps bootstrapping new nodes by indexing nodes that are present in the network and returning a random sample when queried.

In addition the seed provides a way to query for specific nodes, e.g., allowing nodes to quickly find their peers even though the switched IP or port.

Supported Queries

Generally this implementation supports both IPv4 and IPv6 queries, i.e., A and AAAA queries. In addition it supports SRV queries that return a mix of IPv4 nodes and IPv6 nodes, and their associated A and AAAA answers.

A & AAAA Queries

The seed answers incoming A and AAAA queries with up to 25 known nodes in the network. The nodes are filtered by their listening port, and only nodes that listen on the default Lightning port, 9735, are returned. This is necessary since it is not possible to specify the port in A and AAAA answers.

SRV Queries

Upon receiving an SRV query the seed will sample up to 25 nodes from the known nodes, regardless of their listening port, and return them, specifying an alias and the port. The SRV query attempts to return a balanced set of IPv4 and IPv6 nodes.

In addition to the alias and port, the seed will also attach the matching A and AAAA records, such that a single query return both IP and port, and nodes may initiate connections without further queries.

Node Queries (A & AAAA)

Given the alias from the SRV queries, a client can also directly query for a specific node. If the node's ID is ln1qvxsm6rcnr7wtsfktk5j8990wyr307u705u4dkht469ef94kxrsfwjf5e6m then the corresponding alias will be:

ln1qvxsm6rcnr7wtsfktk5j8990wyr307u705u4dkht469ef94kxrsfwjf5e6m.nodes.lightning.directory`

The node's public key is returned encoded as a bech32 string. In order to obtain the raw public key, one will first need to decode the bech32 string, and then regroup the 5-bit words into 8-bit words.

The leading 0 character is removed from the pubkey, and the pubkey is split into two chunks. The first chunk is 63 characters long, while the second chunk is 2 characters long. The two chunks are then dot-separated and prefixed to the seed's domain, nodes.lightning.directory in this case.

The answer contains the record matching the query, or the record of the other IP version type in the additional section if IP versions do not match.

Information Source

Currently the seed will poll a local Lightning node periodically and update its local view accordingly. In future I'd like to introduce a number of different information sources and add further tests, such as testing for reachability before returning nodes.

lseed's People

Contributors

roasbeef avatar cdecker avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.