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.
This commit is contained in:
Christian Decker 2020-03-04 14:24:01 +01:00
parent 959687bf6d
commit ac5cba2243
2 changed files with 6 additions and 4 deletions

View File

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

View File

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