This package has been deprecated

Author message:

Moved to @node-lightning/graph

@lntools/graph
TypeScript icon, indicating that this package has built-in type declarations

0.8.0 • Public • Published

@lntools/graph

This library constructs a graph as an adjacency list from P2P gossip messages.

This class includes the following types:

  • GraphManger - constructs a graph from gossip messages
  • Graph - adjacency list representation of a graph
  • Node - vertex in the graph
  • Channel - directional edge in the graph
  • ChannelSettings - one directional edge information

Examples

Message from a gossip emitter (defined in @lntools/wire) will be used to construct an adjacency list based graph.

const graphManager = new GossipManager(gossipEmitter);

graphManager.on("node", (node: Node) => {
  //
});

graphManager.on("channel", (channel: Channel) => {
  //
});

graphManager.on("channel_update", (channel: Channel, settings: ChannelSettings) => {
  //
});

The following events are emitted for the corresponding gossip message:

channel_announcement message

  • emits node event for node1 in channel
  • emits node event for node2 in channel
  • emits channel

channel_update message

  • emits channel_update event

node_announcement message

  • emits node event

LND Serialization

You can serialize the graph instance in the same manner as the serialization used in LND RPC calls.

const serializer = new LndSerializer();
// to a plain-old JavaScript object
serializer.toObject(graph);

// to JSON
serializer.toJson(graph);

Package Sidebar

Install

npm i @lntools/graph

Weekly Downloads

0

Version

0.8.0

License

MIT

Unpacked Size

274 kB

Total Files

84

Last publish

Collaborators

  • bmancini55