Skip to content

Commit 477f574

Browse files
cdeckerrustyrussell
authored andcommitted
htlc: Keep the parsed TLV payload around with the htlc_in
We want to show the fields in the invoice_payment hook.
1 parent edf4b41 commit 477f574

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

common/onion.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
306306
/* If they somehow got an invalid onion this far, fail. */
307307
if (!cursor)
308308
return tal_free(p);
309+
p->tlv = NULL;
309310
return p;
310311

311312
case ONION_TLV_PAYLOAD:
@@ -404,7 +405,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
404405
*p->total_msat
405406
= amount_msat(tlv->payment_data->total_msat);
406407
}
407-
tal_free(tlv);
408+
p->tlv = tal_steal(p, tlv);
408409
return p;
409410
}
410411

common/onion.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ struct onion_payload {
2424
/* If blinding is set, blinding_ss is the shared secret.*/
2525
struct pubkey *blinding;
2626
struct secret blinding_ss;
27+
28+
/* The raw TLVs contained in the payload. */
29+
struct tlv_tlv_payload *tlv;
2730
};
2831

2932
u8 *onion_nonfinal_hop(const tal_t *ctx,

lightningd/htlc_end.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ struct htlc_in {
5858

5959
/* A simple text annotation shown in `listpeers` */
6060
char *status;
61+
62+
/* The decoded onion payload after hooks processed it. */
63+
struct onion_payload *payload;
6164
};
6265

6366
struct htlc_out {

lightningd/peer_htlcs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS)
10771077

10781078
request->hin->status = tal_free(request->hin->status);
10791079

1080+
/* Hand the payload to the htlc_in since we'll want to have that info
1081+
* handy for the hooks and notifications. */
1082+
request->hin->payload = tal_steal(request->hin, request->payload);
1083+
10801084
/* *Now* we barf if it failed to decode */
10811085
if (!request->payload) {
10821086
log_debug(channel->log,

0 commit comments

Comments
 (0)