Lnd: Cannot balance channels by sending self payments

Created on 13 Dec 2017  路  4Comments  路  Source: lightningnetwork/lnd

Bob has two channels, CH1 to Alice, and CH2 to Charlie. Bob notices that these two channels are very unbalanced; CH1 has 1000 SAT local to Bob and 9000 SAT local to Alice, likewise CH2.

              CH1                      CH2                          CH3
Alice[9000]--------->[1000]Bob[9000]--------->[1000]Charlie[9000]--------->[1000]Alice

Bob wants to balance this and wishes to send himself 4000 SAT via CH2->CH3->CH1. This would result in the following updated state:

              CH1                      CH2                          CH3
Alice[5000]--------->[5000]Bob[5000]--------->[5000]Charlie[5000]--------->[5000]Alice

Unfortunately, this does not work with the current implementation. First of all, it is not possible to select a specific route at the command line. Second of all, even in this very simple example when there is only a single route from Bob to Bob, the payment fails:

$ lncli-alice openchannel 03ab7d85f11f2429b94ce29c7b09b1ae38bb8fa05995b06d42d193e6d08f7f79a5 10000 1000
$ lncli-bob openchannel 02785eca55d76465aa6f18dc6d7fd6dba2fc7aa47e232543aa17019c77bf909d58 10000 1000
$ lncli-charlie openchannel 0237b82dfb5bab416142108b011cbd354550a9c7e16aa674cc3d213f0e5b4b2d1b 10000 1000
$ lncli-bob addinvoice 4000
$ lncli-bob payinvoice lnsb40u1pdrztnrpp52dmf52s3da42377ldamwl8cyxa56uceg6exywusf6dgfsmez5ldqdqqcqzys4a7mgxd75y0efscnz9wdj2zvppa9a3ct79p5cpt6wnfhs0r4y6kzzl2fjek96t0y3ydaau0x363kddhvs8xzrlp03ha7kynquja5uegq4m6qff
{
        "payment_error": "unable to find a path to destination",
        "payment_preimage": "",
        "payment_route": null
}
enhancement intermediate multi-hop payments routing rpc

Most helpful comment

Now possible with the addition of SendToRoute.

All 4 comments

Yep you're correct, this current implementation's default path finding doesn't allow circular routes. There's a pending PR for a sendroutes command which would let a higher level interface _manually_ craft a circular route. This was rolled into @cfromknecht's off-chain swap branch to allow swapping between BTC and LTC: https://github.com/cfromknecht/lnd/commits/swapz

A first step to exposing this to the user would be to extract the finished and up to date sendroutes RPC from the above branch, so that can land as a distinct RPC (as it has several uses including channel rebalancing). The most minimal interface to rebalancing would be to expose it as a new command line option (once sendroutes is added as an RPC). This new command would use describegraph to do manual path finding, or rely on another command (or internal RPC) to return a set of routes that satisfied a set of constrains (ex: start at time, end at me, send at least 1500 SA). Users could then use this to manually rebalance as they wished.

A higher level approach would be to create a new external program or sub-system (package within lnd) that receives signals from the switch pertaining to the up to date available bandwidths of reach link. The system (given a set of constraining heuristics) would then attempt to _passively_ rebalance channels.

I think both approaches have their merits.

Can I work on this issue? I am thinking on try it with the first approach.

There is an open PR related with add the sendToRoute command to RPC, this one: #747.

I can get from there and create a command to get possible routes for rebalancing and one command to rebalance.

Would that be a good approach?

@vctt94 ideally those are rolled into a single command with maybe a "dry run" flag. The "rebalancechan" command itself can be composed over several other distinct commands. Your break down is correct: find set of possible routes to execute, serially execute each of those routes. It may be possible that a candidate route (pre-AMP) is unable to _fully_ rebalance the channel. In that case, the main loop will need to be re-executed in order to find other candidate routes.

Now possible with the addition of SendToRoute.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

whizz picture whizz  路  3Comments

stevenroose picture stevenroose  路  3Comments

joostjager picture joostjager  路  3Comments

BitBargain picture BitBargain  路  3Comments

Roasbeef picture Roasbeef  路  3Comments