htlc: Keep the parsed TLV payload around with the htlc_in

We want to show the fields in the invoice_payment hook.
This commit is contained in:
Christian Decker 2021-06-17 15:16:55 +02:00 committed by Rusty Russell
parent edf4b416c2
commit 477f574569
4 changed files with 12 additions and 1 deletions

View File

@ -306,6 +306,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
/* If they somehow got an invalid onion this far, fail. */
if (!cursor)
return tal_free(p);
p->tlv = NULL;
return p;
case ONION_TLV_PAYLOAD:
@ -404,7 +405,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
*p->total_msat
= amount_msat(tlv->payment_data->total_msat);
}
tal_free(tlv);
p->tlv = tal_steal(p, tlv);
return p;
}

View File

@ -24,6 +24,9 @@ struct onion_payload {
/* If blinding is set, blinding_ss is the shared secret.*/
struct pubkey *blinding;
struct secret blinding_ss;
/* The raw TLVs contained in the payload. */
struct tlv_tlv_payload *tlv;
};
u8 *onion_nonfinal_hop(const tal_t *ctx,

View File

@ -58,6 +58,9 @@ struct htlc_in {
/* A simple text annotation shown in `listpeers` */
char *status;
/* The decoded onion payload after hooks processed it. */
struct onion_payload *payload;
};
struct htlc_out {

View File

@ -1077,6 +1077,10 @@ htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS)
request->hin->status = tal_free(request->hin->status);
/* Hand the payload to the htlc_in since we'll want to have that info
* handy for the hooks and notifications. */
request->hin->payload = tal_steal(request->hin, request->payload);
/* *Now* we barf if it failed to decode */
if (!request->payload) {
log_debug(channel->log,