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