alexbosworth / ln-service

Node.js interface to LND
MIT License
318 stars 61 forks source link

Unexpected error when paying via route #110

Closed apotdevin closed 4 years ago

apotdevin commented 4 years ago

Trying to make a circular payment I was getting an unexpected error. Decided to try from the basic of paying via a route as shown in the documentation with:

const {getRoutes, payViaRoutes} = require('ln-service');
const destination = 'destinationPublicKeyHexString';
const tokens = 80085;
const {routes} = await getRoutes({destination, lnd, tokens});
const preimage = (await payViaRoutes({lnd, routes})).secret;

but keep getting:

[
  503,
  'UnexpectedErrorWhenPayingViaRoute',
  {
    failures: [
      [
        503,
        'UnexpectedErrorWhenPayingViaRoute',
        { err: [Error] },
        [length]: 3
      ],
      [length]: 1
    ]
  },
  [length]: 3
]

Don't know what i'm missing here

alexbosworth commented 4 years ago

This may be a better example to go off of for a circular payment: https://github.com/alexbosworth/ln-service/blob/master/test/integration/test_rebalance.js

apotdevin commented 4 years ago

Great, tested it and payment goes through when I only do one hop (Control node -> Target Node -> Control node).

For a longer path any recommended way to get the route? Since the getRoute example in this link would give me only a one hop route as above

alexbosworth commented 4 years ago

Here is a more complex example of rebalancing: https://github.com/alexbosworth/balanceofsatoshis/blob/master/swaps/rebalance.js

apotdevin commented 4 years ago

Will have a look! Thanks

apotdevin commented 4 years ago

Excited to try out the in house channel balancing coming with LND 9

alexbosworth commented 4 years ago

The 0.9.0 circular rebalancing works a bit differently so I've split the getRoutes method into two methods: getRoutes and getRouteToDestination in order to support both methods