Lightning-Network

如何通過保存在 json 中的路由發送付款?

  • February 11, 2019

來自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

我使用此命令將路由保存在 json 文件中:

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

然後從規範中,執行:

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

我總是得到這個錯誤:

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

難道我做錯了什麼?我應該設置什麼作為 –routes 參數?

我認為問題在於您試圖將文件名作為參數而不是文件的內容傳遞。嘗試通過標準輸入傳遞 json:

cat routes.json | lncli --network=testnet sendtoroute --payment_hash=...

引用自:https://bitcoin.stackexchange.com/questions/84439