0

I am looking for a way to find all the available connections and channels in the lightning network.

For example, if you go to www.1ml.com/testnet, you can see the number of nodes and number of connections. Somehow they achieve this information. How can I achieve it without going to their website and looking at it. Is there a code to do that?

Secondly, how can I find the list of all active nodes and channels in LN. Is there a code to do that?

Have a nice day!

Bit111
  • 11
  • 1

1 Answers1

1

Generally the information you seek is propagated through the gossip protocol of the peer 2 peer network of the lightning network protocol. (though this will only include public channels and nodes. Every node and channel owner can decide to keep their own information private)

Thus every lightning implementation will have access to most of the information displayed on 1ml.com. You can either use a client library to program against the api of an implementation.

Easier would be to just get the information on the command line. So in clightning you can call lightning-cli listchannels and lightning-cli listnodes. With lnd it should be only one api call describechannelgraph to get both information. As mentioned both commands exist also in client libraries.

To see if nodes are online you have to connect to them.

Rene Pickhardt
  • 692
  • 5
  • 17
  • Generally this question would have been better posted on Bitcoin.stackexchange.com – Rene Pickhardt Apr 29 '19 at 19:38
  • However, my questions are how to get pubKey information? Randomly try to connect some pubkeys? No, somehow I should get the list of the active nodes. Just to clarify, by using lightning-cli listchannels and lightning-cli listnodes will return the connections and channels I have with those nodes. I am looking into describechannelgraph from https://api.lightning.community/#describegraph I trying to figure out how to use it. But still there is a problem, how can I get the vertexs of nodes I am connected. A is me. A -> B, I can reach to B. But B->C. Is there a way to get C from A? – Bit111 Apr 29 '19 at 20:32
  • There are seed nodes wich you can query via dns. So that you know some initial peers from which you can dow load the gossip messages. The c-lightning call returns all known public nodes and channels independent if your own channels or connections. (you need to have at least 1 connection because otherwise you don't have the gossip messages). I don't get the last part of your question – Rene Pickhardt Apr 29 '19 at 21:55