Skip to content

Commit edf4b41

Browse files
cdeckerrustyrussell
authored andcommitted
htlc: Wire extra TLV types into the HTLC onion decoding
1 parent b4ead97 commit edf4b41

File tree

7 files changed

+12
-6
lines changed

7 files changed

+12
-6
lines changed

common/onion.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
267267
const struct route_step *rs,
268268
const struct pubkey *blinding,
269269
const struct secret *blinding_ss,
270+
u64 *accepted_extra_tlvs,
270271
u64 *failtlvtype,
271272
size_t *failtlvpos)
272273
{
@@ -312,7 +313,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
312313
if (!fromwire_tlv_payload(&cursor, &max, tlv))
313314
goto fail;
314315

315-
if (!tlv_payload_is_valid(tlv, failtlvpos)) {
316+
if (!tlv_fields_valid(tlv->fields, accepted_extra_tlvs, failtlvpos)) {
316317
*failtlvtype = tlv->fields[*failtlvpos].numtype;
317318
goto fail;
318319
}

common/onion.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ size_t onion_payload_length(const u8 *raw_payload, size_t len,
6868
* onion_payload_length().
6969
* @blinding: the optional incoming blinding point.
7070
* @blinding_ss: the shared secret derived from @blinding (iff that's non-NULL)
71+
* @accepted_extra_tlvs: Allow these types to be in the TLV without failing
7172
* @failtlvtype: (out) the tlv type which failed to parse.
7273
* @failtlvpos: (out) the offset in the tlv which failed to parse.
7374
*
@@ -77,6 +78,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
7778
const struct route_step *rs,
7879
const struct pubkey *blinding,
7980
const struct secret *blinding_ss,
81+
u64 *accepted_extra_tlvs,
8082
u64 *failtlvtype,
8183
size_t *failtlvpos);
8284

lightningd/peer_htlcs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ static bool htlc_accepted_hook_deserialize(struct htlc_accepted_hook_payload *re
927927
rs->raw_payload = prepend_length(rs, take(payload));
928928
request->payload = onion_decode(request, rs,
929929
hin->blinding, &hin->blinding_ss,
930+
ld->accept_extra_tlv_types,
930931
&request->failtlvtype,
931932
&request->failtlvpos);
932933

@@ -1243,6 +1244,7 @@ static bool peer_accepted_htlc(const tal_t *ctx,
12431244
hook_payload->route_step = tal_steal(hook_payload, rs);
12441245
hook_payload->payload = onion_decode(hook_payload, rs,
12451246
hin->blinding, &hin->blinding_ss,
1247+
ld->accept_extra_tlv_types,
12461248
&hook_payload->failtlvtype,
12471249
&hook_payload->failtlvpos);
12481250
hook_payload->ld = ld;

wallet/db_postgres_sqlgen.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wallet/db_sqlite3_sqlgen.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wallet/statements_gettextgen.po

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wallet/test/run-wallet.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ struct onion_payload *onion_decode(const tal_t *ctx UNNEEDED,
525525
const struct route_step *rs UNNEEDED,
526526
const struct pubkey *blinding UNNEEDED,
527527
const struct secret *blinding_ss UNNEEDED,
528+
u64 *accepted_extra_tlvs UNNEEDED,
528529
u64 *failtlvtype UNNEEDED,
529530
size_t *failtlvpos UNNEEDED)
530531
{ fprintf(stderr, "onion_decode called!\n"); abort(); }

0 commit comments

Comments
 (0)