Skip to content

Commit e74861a

Browse files
committed
common: remove legacy onion translation.
This was added in 24.05, but LND since 0.18.3 no longer ever creates such onions, and even that version (September 2024) is now a long way behind. Signed-off-by: Rusty Russell <[email protected]> Changelog-Removed: Protocol: we no longer support legacy onions (never sent by LND >= 0.18.3, which was the last)
1 parent c04aaa1 commit e74861a

File tree

1 file changed

+6
-47
lines changed

1 file changed

+6
-47
lines changed

common/sphinx.c

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -677,54 +677,13 @@ struct route_step *process_onionpacket(
677677
/* Any of these could fail, falling thru with cursor == NULL */
678678
payload_size = fromwire_bigsize(&cursor, &max);
679679

680-
/* Legacy! 0 length payload means fixed 32 byte structure */
681-
if (payload_size == 0 && max >= 32) {
682-
struct tlv_payload *legacy = tlv_payload_new(tmpctx);
683-
const u8 *legacy_cursor = cursor;
684-
size_t legacy_max = 32;
685-
u8 *onwire_tlv;
686-
687-
legacy->amt_to_forward = tal(legacy, u64);
688-
legacy->outgoing_cltv_value = tal(legacy, u32);
689-
legacy->short_channel_id = tal(legacy, struct short_channel_id);
690-
691-
/* BOLT-obsolete #4:
692-
* ## Legacy `hop_data` payload format
693-
*
694-
* The `hop_data` format is identified by a single `0x00`-byte
695-
* length, for backward compatibility. Its payload is defined
696-
* as:
697-
*
698-
* 1. type: `hop_data` (for `realm` 0)
699-
* 2. data:
700-
* * [`short_channel_id`:`short_channel_id`]
701-
* * [`u64`:`amt_to_forward`]
702-
* * [`u32`:`outgoing_cltv_value`]
703-
* * [`12*byte`:`padding`]
704-
*/
705-
*legacy->short_channel_id = fromwire_short_channel_id(&legacy_cursor, &legacy_max);
706-
*legacy->amt_to_forward = fromwire_u64(&legacy_cursor, &legacy_max);
707-
*legacy->outgoing_cltv_value = fromwire_u32(&legacy_cursor, &legacy_max);
708-
709-
/* Re-linearize it as a modern TLV! */
710-
onwire_tlv = tal_arr(tmpctx, u8, 0);
711-
towire_tlv_payload(&onwire_tlv, legacy);
712-
713-
/* Length, then tlv */
714-
step->raw_payload = tal_arr(step, u8, 0);
715-
towire_bigsize(&step->raw_payload, tal_bytelen(onwire_tlv));
716-
towire_u8_array(&step->raw_payload, onwire_tlv, tal_bytelen(onwire_tlv));
680+
/* FIXME: raw_payload *includes* the length, which is redundant and
681+
* means we can't just ust fromwire_tal_arrn. */
682+
fromwire_pad(&cursor, &max, payload_size);
683+
if (cursor != NULL)
684+
step->raw_payload = tal_dup_arr(step, u8, paddedheader,
685+
cursor - paddedheader, 0);
717686

718-
payload_size = 32;
719-
fromwire_pad(&cursor, &max, payload_size);
720-
} else {
721-
/* FIXME: raw_payload *includes* the length, which is redundant and
722-
* means we can't just ust fromwire_tal_arrn. */
723-
fromwire_pad(&cursor, &max, payload_size);
724-
if (cursor != NULL)
725-
step->raw_payload = tal_dup_arr(step, u8, paddedheader,
726-
cursor - paddedheader, 0);
727-
}
728687
fromwire_hmac(&cursor, &max, &step->next->hmac);
729688

730689
/* BOLT #4:

0 commit comments

Comments
 (0)