htlc: Wire extra TLV types into the HTLC onion decoding

This commit is contained in:
Christian Decker 2021-06-17 13:00:24 +02:00 committed by Rusty Russell
parent b4ead97517
commit edf4b416c2
7 changed files with 12 additions and 6 deletions

View File

@ -267,6 +267,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
const struct route_step *rs,
const struct pubkey *blinding,
const struct secret *blinding_ss,
u64 *accepted_extra_tlvs,
u64 *failtlvtype,
size_t *failtlvpos)
{
@ -312,7 +313,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
if (!fromwire_tlv_payload(&cursor, &max, tlv))
goto fail;
if (!tlv_payload_is_valid(tlv, failtlvpos)) {
if (!tlv_fields_valid(tlv->fields, accepted_extra_tlvs, failtlvpos)) {
*failtlvtype = tlv->fields[*failtlvpos].numtype;
goto fail;
}

View File

@ -68,6 +68,7 @@ size_t onion_payload_length(const u8 *raw_payload, size_t len,
* onion_payload_length().
* @blinding: the optional incoming blinding point.
* @blinding_ss: the shared secret derived from @blinding (iff that's non-NULL)
* @accepted_extra_tlvs: Allow these types to be in the TLV without failing
* @failtlvtype: (out) the tlv type which failed to parse.
* @failtlvpos: (out) the offset in the tlv which failed to parse.
*
@ -77,6 +78,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
const struct route_step *rs,
const struct pubkey *blinding,
const struct secret *blinding_ss,
u64 *accepted_extra_tlvs,
u64 *failtlvtype,
size_t *failtlvpos);

View File

@ -927,6 +927,7 @@ static bool htlc_accepted_hook_deserialize(struct htlc_accepted_hook_payload *re
rs->raw_payload = prepend_length(rs, take(payload));
request->payload = onion_decode(request, rs,
hin->blinding, &hin->blinding_ss,
ld->accept_extra_tlv_types,
&request->failtlvtype,
&request->failtlvpos);
@ -1243,6 +1244,7 @@ static bool peer_accepted_htlc(const tal_t *ctx,
hook_payload->route_step = tal_steal(hook_payload, rs);
hook_payload->payload = onion_decode(hook_payload, rs,
hin->blinding, &hin->blinding_ss,
ld->accept_extra_tlv_types,
&hook_payload->failtlvtype,
&hook_payload->failtlvpos);
hook_payload->ld = ld;

View File

@ -1924,4 +1924,4 @@ struct db_query db_postgres_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:0cb27df4073d1a617d3d1712579e28c190208818458ea8b35c3c88276b428dc0
// SHA256STAMP:3c0924d3409c1d356d9f90291ae54895d85f34c6a3a42388ad4fb6bfbf13820d

View File

@ -1924,4 +1924,4 @@ struct db_query db_sqlite3_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:0cb27df4073d1a617d3d1712579e28c190208818458ea8b35c3c88276b428dc0
// SHA256STAMP:3c0924d3409c1d356d9f90291ae54895d85f34c6a3a42388ad4fb6bfbf13820d

View File

@ -1262,11 +1262,11 @@ msgstr ""
msgid "not a valid SQL statement"
msgstr ""
#: wallet/test/run-wallet.c:1450
#: wallet/test/run-wallet.c:1451
msgid "SELECT COUNT(1) FROM channel_funding_inflights WHERE channel_id = ?;"
msgstr ""
#: wallet/test/run-wallet.c:1648
#: wallet/test/run-wallet.c:1649
msgid "INSERT INTO channels (id) VALUES (1);"
msgstr ""
# SHA256STAMP:af00e095200a0cdcd525759a786e1897d11a0effffd7d4b9d618bfa780acd229
# SHA256STAMP:913e7b10afc4160e8b437a2c54839d996a94667fc0c00a22f3ca97856491ac72

View File

@ -525,6 +525,7 @@ struct onion_payload *onion_decode(const tal_t *ctx UNNEEDED,
const struct route_step *rs UNNEEDED,
const struct pubkey *blinding UNNEEDED,
const struct secret *blinding_ss UNNEEDED,
u64 *accepted_extra_tlvs UNNEEDED,
u64 *failtlvtype UNNEEDED,
size_t *failtlvpos UNNEEDED)
{ fprintf(stderr, "onion_decode called!\n"); abort(); }