jitrebalance: handle the absence of the 'erring_channel' field

On failed 'sendpay'.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
Antoine Poinsot
2020-05-25 11:40:58 +02:00
committed by Christian Decker
parent 18632df38c
commit 386d4eaa6d

View File

@@ -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"})