noise: Allow malformed onion if it's the last hop

This was counted as a failure before, but it actually means we delivered
successfully.
This commit is contained in:
Christian Decker
2020-01-19 12:54:33 +01:00
parent 374fdadcbe
commit 3d3c7f75ba

View File

@@ -90,9 +90,9 @@ def deliver(node_id, payload, amt, max_attempts=5, payment_hash=None):
plugin.rpc.waitsendpay(payment_hash=payment_hash)
return {'route': route, 'payment_hash': payment_hash, 'attempt': attempt}
except RpcError as e:
print(e)
failcode = e.error['data']['failcode']
if failcode == 16399:
failingidx = e.error['data']['erring_index']
if failcode == 16399 or failingidx == len(hops):
return {'route': route, 'payment_hash': payment_hash, 'attempt': attempt+1}
plugin.log("Retrying delivery.")