From 386d4eaa6dfb0b6162d75340e344321c2960b0f4 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Mon, 25 May 2020 11:40:58 +0200 Subject: [PATCH] jitrebalance: handle the absence of the 'erring_channel' field On failed 'sendpay'. Signed-off-by: Antoine Poinsot --- jitrebalance/jitrebalance.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jitrebalance/jitrebalance.py b/jitrebalance/jitrebalance.py index 8f14c03..187b46e 100755 --- a/jitrebalance/jitrebalance.py +++ b/jitrebalance/jitrebalance.py @@ -91,10 +91,15 @@ def try_rebalance(scid, chan, amt, peer, request): return except RpcError as e: error = e.error['data'] - erring_channel = error['erring_channel'] - erring_direction = error['erring_direction'] - exclusions.append("{}/{}".format(erring_channel, erring_direction)) - plugin.log("Excluding {} due to a failed attempt".format(erring_channel)) + # The erring_channel field can not be present (shouldn't happen) or + # can be "0x0x0" + erring_channel = error.get('erring_channel', '0x0x0') + if erring_channel != '0x0x0': + erring_direction = error['erring_direction'] + exclusions.append("{}/{}".format(erring_channel, + erring_direction)) + plugin.log("Excluding {} due to a failed attempt" + .format(erring_channel)) request.set_result({"result": "continue"})