sphinx: Use the new fromwire_tlv_payload function

We wire in the code-generated function, which removes the upfront validation
and add the validation back after the `htlc_accepted` hook returns. If a
plugin wanted to handle the onion in a special way it'll not have told us to
just continue.
This commit is contained in:
Christian Decker
2019-11-18 20:10:58 +01:00
committed by Rusty Russell
parent 2519f934aa
commit d69a43780c
3 changed files with 12 additions and 10 deletions

View File

@@ -781,7 +781,11 @@ htlc_accepted_hook_callback(struct htlc_accepted_hook_payload *request,
switch (result) {
case htlc_accepted_continue:
if (rs->nextcase == ONION_FORWARD) {
if (rs->type == SPHINX_TLV_PAYLOAD && !tlv_payload_is_valid(rs->payload.tlv)) {
log_debug(channel->log, "Failing HTLC because of an invalid TLV payload");
failure_code = WIRE_INVALID_ONION_PAYLOAD;
fail_in_htlc(hin, failure_code, NULL, request->short_channel_id);
}else if (rs->nextcase == ONION_FORWARD) {
struct gossip_resolve *gr = tal(ld, struct gossip_resolve);
gr->next_onion = serialize_onionpacket(gr, rs->next);