LN Toolkit Command

find-routes’ command

find-routes tries to find viable routes from one channel+pubkey to another channel+pubkey

This is handy for ‘go’ developers, but probably not too many others. Everyone else can use the lncli command to download the graph, but it’s not quite the right format to unmarshal into the ‘go’ lnrpc data structures.


Finding routes is hard, can take a long time, and there just may not be any route available.


Here’s a simple example of running the command:

find-routes --from 1601702568650604544 --to 1600752590601781248 --to-pub-key 03236a685d30096b26692dce0cf0fa7c8528bdf61dbf5363a3ef6d5c92733a3016 --amount 100000 --verbose --max-routes 1

This will try to find the single cheapest route (specified as --max-routes 1) that can carry 100000 sats (specified as --amount 100000) from channel 1601702568650604544 (specified as --from 1601702568650604544) on your node (no specifying --from-pub-key) to channel 1600752590601781248 (specified as --to 1600752590601781248) ending at node with pubkey 03236a685d30096b26692dce0cf0fa7c8528bdf61dbf5363a3ef6d5c92733a3016 (specified as --to-pub-key 03236a685d30096b26692dce0cf0fa7c8528bdf61dbf5363a3ef6d5c92733a3016).

Here’s a sample output of that run:

2019/03/29 19:41:45 📄 Payment path[0]:
  Current block height: 1486503
  Move: 100000000 msat
  From channel: 1600752590601781248
  To channel:   1601702568650604544
  Cost: 1100 msat
	⚡ OpinionatedGeek Test ⚡ (36 channels)
		Channel ID: 1601702568650604544	Capacity: 16777215	Cost: 1100 msat
			Src: 02639adf914ec9dfd8649c47de1d232de4a23b0719b1d8bd2bef9beb32f948018e -
			Dst: 03b6384db3982ba0f87bec1155633de02296b650b08290d8c9e811da3a07bcf595
	⚡ Goliath (76 channels)
		Channel ID: 1600752590601781248	Capacity: 16777215	Cost: 0 msat
			Src: 03b6384db3982ba0f87bec1155633de02296b650b08290d8c9e811da3a07bcf595 -
			Dst: 03236a685d30096b26692dce0cf0fa7c8528bdf61dbf5363a3ef6d5c92733a3016
	⚡ dead.cash (476 channels)
2019/03/29 19:41:45 📄 No tip to send. That's OK, I still love you! 🥰

If you use the --verbose flag, it will also output a JSON representation of the route with some more details:

2019/03/29 19:41:45 🏷  Route: {
	"total_time_lock": 1486791,
	"total_fees": 1,
	"total_amt": 100001,
	"hops": [
			"chan_id": 1601702568650604544,
			"chan_capacity": 16777215,
			"amt_to_forward": 100000,
			"fee": 1,
			"expiry": 1486647,
			"amt_to_forward_msat": 100000000,
			"fee_msat": 1100,
			"pub_key": "03b6384db3982ba0f87bec1155633de02296b650b08290d8c9e811da3a07bcf595"
			"chan_id": 1600752590601781248,
			"chan_capacity": 16777215,
			"amt_to_forward": 100000,
			"expiry": 1486647,
			"amt_to_forward_msat": 100000000,
			"pub_key": "03236a685d30096b26692dce0cf0fa7c8528bdf61dbf5363a3ef6d5c92733a3016"
	"total_fees_msat": 1100,
	"total_amt_msat": 100001100


Here’s the list of parameters it can take:

Usage of find-routes:
  -amount value
    	amount used as payload when finding the route
  -certificate string
    	path and filename of the TLS certificate to use when connecting to LND. (default "~/.lnd/tls.cert")
  -final-cltv-delta uint
    	final CLTV delta to use in the routes from the 'from' channel to the 'to' channel. (default 144)
  -from value
    	the channel ID to be the start of the route
  -from-pub-key value
    	the pub key of the 'from' node (defaults to this node's pub key)
  -macaroon string
    	path and filename of the macaroon to use when connecting to LND. (default "~/.lnd/data/chain/bitcoin/testnet/admin.macaroon")
  -max-fees-msat value
    	maximum fees (in msat) to be spent on the balance move. (default m㋛10,000)
  -max-hops int
    	maximum number of hops in routes used for the balance move. (default 20)
  -max-routes int
    	maximum number of routes to try (cheapest first) when trying to move the balance. (default 20)
  -max-search-time duration
    	maximum length of time waiting while searching for the next route. (default 30s)
    	only show errors and critical messages.
  -server string
    	hostname and port to use when connecting to LND. (default "localhost:10009")
  -timeout duration
    	timeout to use when connecting to LND. (default 30s)
  -tip value
    	tip amount (in satoshis) to the developer as a thank-you (Tip is only paid if an action is performed.)
  -to value
    	the channel ID to be the end of the route
  -to-pub-key value
    	the pub key of the 'to' node (defaults to this node's pub key)
    	show additional logging information.
    	report the version being used.

Like all LN Toolkit commands, find-routes can take a --verbose flag to greatly increase the amount of diagnostic output it creates (including JSON representations of routes, if you like that kind of thing). It can also take a --tip <amount> parameter if you want to tip me some satoshis.