I'm trying to write some services on top of c-lightning and I need to check if certain payments hit certain nodes.

lightning-cli getroute nodeid amount riskfactor

This gives me a randomly selected single route out of potential two routes.

Is it possible for me to get all potential routes and decide for myself?

1 Answer 1


if you invest some programming time you can use the listchannels command to retrieve all channels of the lightning network from the gossip store. No you could store them in the networkx lib

import networkx as nx
network = ln.listchannels()
for channel in network:                                                                                                        

and then you could use this algorithm from the networkx library to get a generator for all paths between a source and a destination rout. Since the lightning network will most likely have cycles you need to define a cutoff. While 20 is to long from a computational point of view it is also the the maximum path length an onion packet supports according to BOLT 04.

Length: the maximum route length is limited to 20 hops.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.