Browse Source

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.
travis-debug
Christian Decker 5 years ago
parent
commit
ac5cba2243
  1. 9
      lightningd/peer_htlcs.c
  2. 1
      tests/test_pay.py

9
lightningd/peer_htlcs.c

@ -981,9 +981,12 @@ htlc_accepted_hook_callback(struct htlc_accepted_hook_payload *request,
case htlc_accepted_continue: case htlc_accepted_continue:
/* *Now* we barf if it failed to decode */ /* *Now* we barf if it failed to decode */
if (!request->payload) { if (!request->payload) {
log_debug(channel->log, "Failing HTLC because of an invalid payload"); log_debug(channel->log,
local_fail_in_htlc_badonion(hin, "Failing HTLC because of an invalid payload");
WIRE_INVALID_ONION_PAYLOAD); local_fail_in_htlc(hin,
take(towire_invalid_onion_payload(
NULL, request->failtlvtype,
request->failtlvpos)));
} else if (rs->nextcase == ONION_FORWARD) { } else if (rs->nextcase == ONION_FORWARD) {
forward_htlc(hin, hin->cltv_expiry, forward_htlc(hin, hin->cltv_expiry,
request->payload->amt_to_forward, request->payload->amt_to_forward,

1
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) assert inv['amount_received_msat'] == Millisatoshi(1001)
@pytest.mark.xfail(strict=True)
def test_reject_invalid_payload(node_factory): def test_reject_invalid_payload(node_factory):
"""Send an onion payload with an unknown even type. """Send an onion payload with an unknown even type.

Loading…
Cancel
Save