I have an active channel with bitstamp with a balance on my side. Bitstamp has an active channel with lightening power users (lpu) with balance on their side (I checked this with lncli queryroutes 0331f80652fb840239df8dc99205792bba2e559a05469915804c08420230e23c7c 70000). Lpu has a channel with me with a balance on their side (I used their service to rent inbound liquidity).

Now since I rented liquidity from lpu only of a couple of days, I will lose inbound liquidity soon. I want to send a payment to myself like so: me -> bitstamp -> lpu -> me. This will result in keeping some inbound liquidity (in my channel with bitstamp) after lpu close our channel.

I suppose I need to use lncli sendtoroute to send payment over a specific route. For this, I need a payment hash and a route. I genereated a payment hash with lncli addinvoice 70000 and copied the r_hash value. I tried to generate a route with lncli queryroutes 0364f45ee43cd4b1d6db08972dfd6ab227e47adccee80ca7d76ae0bd107334c2aa 70000 (that is my pub_key) but I got a "unable to find a path to destination" error.

1st question: Is there a way to get the best route to me with queryroutes?

Then I tried to construct the queryroutes response by myself. I found a route with 3 hops and tried to reverse engineer how fees work. It seems that in hops only the recipient charges a fee. So the first hop is from me to bitstamp (bitstamp charges a fee), the second hop is from bitstamp to lpu (lpu charges a fee), the last hop is from lpu to me (I do not charge a fee to myself).

2nd question: Is the above fee logic correct?

Ok so with all that data I generated queryroutes response below

{ "routes": [ { "total_time_lock": 590112, "total_fees": "373", "total_amt": "70373", "hops": [ { "chan_id": "648038959352250368", "chan_capacity": "100000", "amt_to_forward": "70373", "fee": "0", "expiry": 590072, "amt_to_forward_msat": "70373500", "fee_msat": "70", "pub_key": "02a04446caa81636d60d63b066f2814cbd3a6b5c258e3172cbdded7a16e2cfff4c" }, { "chan_id": "630596306830950400", "chan_capacity": "2500000", "amt_to_forward": "70360", "fee": "360", "expiry": 589928, "amt_to_forward_msat": "70360000", "fee_msat": "13500", "pub_key": "0331f80652fb840239df8dc99205792bba2e559a05469915804c08420230e23c7c" }, { "chan_id": "648098333019668480", "chan_capacity": "500000", "amt_to_forward": "70000", "fee": "360", "expiry": 589928, "amt_to_forward_msat": "70000000", "fee_msat": "360000", "pub_key": "0364f45ee43cd4b1d6db08972dfd6ab227e47adccee80ca7d76ae0bd107334c2aa" } ], "total_fees_msat": "373570", "total_amt_msat": "70373570" } ] }

Then I try to send this with cat my.route | lncli sendtoroute --pay_hash=hashIgenerated - and get a "payment_error": "FeeInsufficient... error.

How should I construct the routes for this to work?

1 Answer 1


First of all, there are already scripts that automate this process. Check C-Otto's rebalance script, for example.

Secondly, I wouldn't assume that finding a route via queryroute guarantees that the balances in the used channels could actually support your payment. I think it just means that the theoretical capacity in your nodes' view of the LN is sufficient. Knowing if the route actually works involves trying to route across it.

To address your concrete questions, I don't know if queryroute supports loops by now, but from glancing over the above script, it appears that it should.

As for your 2nd question, fees are always taken by the node forwarding a payment for sending across a channel, not the recipient in a channel. So if you try to route you-bitstamp-lpu-you, there are only two forwarding hops here, bitstamp and lpu. And they will require the fees that they have announced for the channel bitstamp-lpu (announced and collected by bitstamp) and lpu-you (announced and collected by lpu).

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.