0

From lncli network=testnet sendtoroute -h:

NAME: 
lncli sendtoroute - send a payment over a predefined route
USAGE:
lncli sendtoroute [command options] [arguments...]
DESCRIPTION:
Send a payment over Lightning using a specific route. One must specify
a list of routes to attempt and the payment hash. This command can even
be chained with the response to queryroutes. This command can be used
to implement channel rebalancing by crafting a self-route, or even
atomic swaps using a self-route that crosses multiple chains.
There are three ways to specify routes:
 * using the --routes parameter to manually specify a JSON encoded
   set of routes in the format of the return value of queryroutes:
       (lncli sendtoroute --payment_hash=<pay_hash> --routes=<route>)

 * passing the routes as a positional argument:
       (lncli sendtoroute --payment_hash=pay_hash <route>)

 * or reading in the routes from stdin, which can allow chaining the
   response from queryroutes, or even read in a file with a set of
   pre-computed routes:
       (lncli queryroutes --args.. | lncli sendtoroute --payment_hash= -

   notice the '-' at the end, which signals that lncli should read
   the route in from stdin
OPTIONS:
--payment_hash value, --pay_hash value  the hash to use within the payment's HTLC
--routes value, -r value                a json array string in the format of the response of queryroutes that denotes which routes to use

I use this command to save the routes in a json file:

lncli -network=testnet queryroutes 02e34c1b4c5f8e7419cf4d10e3bc9651d46dc1af68df6a7b81a24951a9192aa9c4 --final_cltv_delta=144 25000->routes.json

Then from the spec, performing:

lncli --network=testnet sendtoroute --payment_hash=03bd33db2dfdebff50ca8a7ae3bade681bbf7f25246248c9416b4441b1dbf4c2 --routes=routes.json

I always get back this error:

[lncli] unable to unmarshal json string from incoming array of routes: invalid character 'r' looking for beginning of value

Am I doing something wrong? What should I set as --routes parameter?

1 Answer 1

3

I think the problem is that you are trying to pass the file name as an argument instead of the content of the file. Try passing the json through the standard input instead:

cat routes.json | lncli --network=testnet sendtoroute --payment_hash=...
7
  • using this i get: [lncli] unable to unmarshal json string from incoming array of routes: invalid character 'â' looking for beginning of value Commented Feb 11, 2019 at 11:42
  • Interesting. Just in case, I assume you do not have a character like this in your routes.json? Commented Feb 11, 2019 at 11:46
  • Exactly. The content of routes.json is just the output of the queryroutes command. Commented Feb 11, 2019 at 11:50
  • 1
    Could you also try passing the routes as a std input? “cat routes.json | lncli sendtoroute ...” Commented Feb 11, 2019 at 13:01
  • 1
    Ok, Actually it works. I was missing the final "-". Here the command: lncli --network=testnet sendtoroute --payment_hash=03bd33db2dfdebff50ca8a7ae3bade681bbf7f25246248c9416b4441b1dbf4c2 --routes="$(cat routes.json)" - Commented Feb 11, 2019 at 14:26

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.