Commit Graph

24 Commits

Author SHA1 Message Date
Michael Schmoock
424770449a jitrebalance: fix missing payment_secret for sendpay 2021-07-23 17:04:14 +02:00
Rusty Russell
87c9f56f75 jitrebalance: fix test for latest c-lightning which required payment_secret
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-07-23 22:03:27 +09:30
Michael Schmoock
258c0e647a jitrebalance: fix flake8 nits 2020-12-13 15:36:15 +01:00
Antoine Poinsot
89a4fa3f59 jitrebalance: handle the failure of the scid lookup in our peers
Somehow, it happened:
```
**BROKEN** lightningd: Plugin for htlc_accepted returned non-result response {"jsonrpc": "2.0", "id": 23, "error": {"code": -32600, "message": "Error while processing htlc_accepted: 'NoneType' object is not subscriptable", "traceback": "Traceback (most recent call last):\n  File \"/home/lightningd/.local/lib/python3.8/site-packages/pyln/client/plugin.py\", line 440, in _dispatch_request\n    result = self._exec_func(method.func, request)\n  File \"/home/lightningd/.local/lib/python3.8/site-packages/pyln/client/plugin.py\", line 427, in _exec_func\n    return func(*ba.args, **ba.kwargs)\n  File \"/home/lightningd/.lightning/plugins/jitrebalance/jitrebalance.py\", line 172, in on_htlc_accepted\n    if not peer['connected'] or chan['state'] != \"CHANNELD_NORMAL\":\nTypeError: 'NoneType' object is not subscriptable\n"}
```

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-10-15 19:35:43 +02:00
Antoine Poinsot
a155107857 jitrebalance: don't set result twice when we can't have a reverse chan
This also moves all logs to get_circular_route, as we have two ways of
returning None.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
4fb91a6f45 jitrebalance: test failure cases
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
afebc21401 jitrebalance: if target scid errors, game is over
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
c5c24cb74a jitrebalance: assert l2 jit-rebalanced in test_simple_rebalance
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
e239fcdcc1 jitrebalance: test_issue_88 needs DEVELOPER too
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
815c382855 jitrebalance: use waitsendpay to wait for htlc resolution
This is a rebalance we initiated, so it's our payment

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
e11fe21dcb jitrebalance: add a configurable timeout to stop trying to rebalance
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
7d900c952b jitrebalance: log on success, don't log the onion
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
61c97e11ef jitrebalance: try as much routes as possible; don't stop at 5
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-06-02 11:59:12 +02:00
Antoine Poinsot
bee26113c0 jitrebalance: don't assume that 'listchannels' results contains 2 entries
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-05-27 14:51:28 +02:00
Antoine Poinsot
386d4eaa6d jitrebalance: handle the absence of the 'erring_channel' field
On failed 'sendpay'.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-05-27 14:51:28 +02:00
Antoine Poinsot
18632df38c jitrebalance: add the direction of erring channel on failed sendpay
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-05-27 14:51:28 +02:00
Christian Decker
d34cb6e637 jitrebalance: Do not attempt to access scid on unconfirmed channels
Fixes #88
2020-05-27 12:34:57 +02:00
Christian Decker
9ebc175542 jitrebalance: Fix error when computing negative msat amounts 2020-05-27 12:34:57 +02:00
Christian Decker
18d03962df jitrebalance: Add a test to reproduce issue #88
I'm expecting it to be because we access the short_channel_id
indiscriminately, which is unsafe if the channel is not confirmed yet, i.e.,
it doesn't have a scid yet.
2020-05-27 12:34:57 +02:00
Christian Decker
ea8e24eb56 fixup! jitrebalance: First version of the JITrebalance plugin 2020-01-07 21:21:11 +01:00
Christian Decker
504d15bfbf jitrebalance: Refactor code and implement retry logic 2020-01-07 21:21:11 +01:00
Christian Decker
9ef45ae83c jitrebalance: Skip tests if not developer, gossip is too slow 2020-01-07 21:21:11 +01:00
Christian Decker
7479c342c4 jitrebalance: Make the plugin TLV compatible 2020-01-07 21:21:11 +01:00
Christian Decker
c453e8982f jitrebalance: First version of the JITrebalance plugin
A simple implementation of a jit-rebalance plugin based in the idea of
@renepickhardt. Upon receiving an HTLC that we are supposed to forward check
whether the channel has sufficient capacity to forward. If that's not the case
we need to rebalance. For this we compute a circular route through some other
nodes, returning funds on the edge we are supposed to use when
forwarding. This means we rebalance the channel just enough to make forwarding
possible.

This only implements the simple version, without FOAF advertisements of free
rebalancings, but it already works rather nicely.

Suggested-by: Rene Pickhardt <@renepickhardt>
Signed-off-by: Christian Decker <@cdecker>
2020-01-07 21:21:11 +01:00