From ac5cba22434c8133934b86f1dcf4f79956341b32 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 4 Mar 2020 14:24:01 +0100 Subject: [PATCH] htlc: Return an invalid payload error if payload is invalid We somehow were always returning `badonion` when really it is an invalid payload inside the onion. --- lightningd/peer_htlcs.c | 9 ++++++--- tests/test_pay.py | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 804c50389..cfed09ca0 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -981,9 +981,12 @@ htlc_accepted_hook_callback(struct htlc_accepted_hook_payload *request, case htlc_accepted_continue: /* *Now* we barf if it failed to decode */ if (!request->payload) { - log_debug(channel->log, "Failing HTLC because of an invalid payload"); - local_fail_in_htlc_badonion(hin, - WIRE_INVALID_ONION_PAYLOAD); + log_debug(channel->log, + "Failing HTLC because of an invalid payload"); + local_fail_in_htlc(hin, + take(towire_invalid_onion_payload( + NULL, request->failtlvtype, + request->failtlvpos))); } else if (rs->nextcase == ONION_FORWARD) { forward_htlc(hin, hin->cltv_expiry, request->payload->amt_to_forward, diff --git a/tests/test_pay.py b/tests/test_pay.py index d4e41fab6..28274c224 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2806,7 +2806,6 @@ caused a crash in 0.8.0, so we then disallowed it. assert inv['amount_received_msat'] == Millisatoshi(1001) -@pytest.mark.xfail(strict=True) def test_reject_invalid_payload(node_factory): """Send an onion payload with an unknown even type.