How to send payment through a predefined route?

2

1

Attempting a payment through a predefined route using:

lncli -network=testnet queryroutes 02e34c1b4c5f8e7419cf4d10e3bc9651d46dc1af68df6a7b81a24951a9192aa9c4 25000 | lncli -network=testnet sendtoroute -pay_hash=45b9255c8648c6c1f60e394e555f745af31ed7fab385d0cf9e82b62ce8e8dfba - 

Always give me back:

{
    "payment_error": "FinalExpiryTooSoon",
    "payment_preimage": "",
    "payment_route": null
}

Regardless the expiry I set in the addinvoice command. Can someone clarify Why? Moreover, how is it possible to use the sendtoroute command using the routes.json obtained before from the queryroutes command?

Stefano Angieri

Posted 2019-02-07T14:16:56.317

Reputation: 133

1Could you try adding “--final_cltv_delta=144” option to your queryroutes command?Dmitry Laptev 2019-02-07T15:00:47.197

Adding this option works!Stefano Angieri 2019-02-07T16:11:15.533

Glad it helped. Added an explanation of why you need this and posted it as an answer.Dmitry Laptev 2019-02-07T16:50:20.563

Answers

4

TL;DR. You need to specify --final_cltv_delta=144 option in the lncli queryroutes command.

Longer answer... When payment is routed through Lightning Network, each intermediate node has a potential ability to steal the funds being transferred. To prevent this from happening, intermediate nodes cannot move the money immediately, but only after a certain period of time. And within this period the funds can be claimed back by a legitimate owner.

final_cltv_delta option specifies this period of time (measured in the number of blocks) for the last node in the chain of hops. When you query routes, the default value is small (I believe it was 9 at some point). But this value is not accepted by most lnd nodes, which require a longer period of 144 by default.

Dmitry Laptev

Posted 2019-02-07T14:16:56.317

Reputation: 436