Skip to content

Commit 5c31d33

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 <rusty@rustcorp.com.au> Changelog-Removed: Protocol: we no longer support legacy onions (never sent by LND >= 0.18.3, which was the last)
1 parent 2c0214f commit 5c31d33

2 files changed

Lines changed: 6 additions & 75 deletions

File tree

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:

tests/test_pay.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5912,34 +5912,6 @@ def test_offer_paths(node_factory, bitcoind):
59125912
l5.rpc.fetchinvoice(offer=offer['bolt12'])
59135913

59145914

5915-
def test_pay_legacy_forward(node_factory, bitcoind, executor):
5916-
"""We removed legacy in 22.11, and LND will still send them for
5917-
route hints! See
5918-
https://github.com/lightningnetwork/lnd/issues/8785
5919-
5920-
"""
5921-
l1, l2, l3 = node_factory.line_graph(3, fundamount=10**6, wait_for_announce=True)
5922-
5923-
inv = l3.rpc.invoice(1000, "inv", "inv")
5924-
5925-
chanid12 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['short_channel_id']
5926-
chanid23 = only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['short_channel_id']
5927-
route = [{'amount_msat': 1011,
5928-
'id': l2.info['id'],
5929-
'delay': 20,
5930-
'channel': chanid12},
5931-
{'amount_msat': 1000,
5932-
'id': l3.info['id'],
5933-
'delay': 10,
5934-
'channel': chanid23}]
5935-
5936-
l1.rpc.call("sendpay", payload={'route': route,
5937-
'payment_hash': inv['payment_hash'],
5938-
'payment_secret': inv['payment_secret'],
5939-
'dev_legacy_hop': True})
5940-
l1.rpc.waitsendpay(inv['payment_hash'])
5941-
5942-
59435915
# CI is so slow under valgrind that this does not reach the ratelimit!
59445916
@pytest.mark.slow_test
59455917
def test_onionmessage_ratelimit(node_factory, executor):

0 commit comments

Comments
 (0)