Skip to content

Commit

Permalink
Switch Trampoline onion ID to 20.
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Mar 8, 2024
1 parent 183bfb2 commit 4021400
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2487,17 +2487,16 @@ impl Writeable for OutboundOnionPayload {
// to reject any reserved types in the experimental range if new ones are ever
// standardized.
let keysend_tlv = keysend_preimage.map(|preimage| (5482373484, preimage.encode()));
let trampoline_tlv = trampoline_packet.as_ref().map(|trampoline| (66100, trampoline.encode()));
let mut custom_tlvs: Vec<&(u64, Vec<u8>)> = custom_tlvs.iter()
.chain(keysend_tlv.iter())
.chain(trampoline_tlv.iter())
.collect();
custom_tlvs.sort_unstable_by_key(|(typ, _)| *typ);
_encode_varint_length_prefixed_tlv!(w, {
(2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required),
(4, HighZeroBytesDroppedBigSize(*cltv_expiry_height), required),
(8, payment_data, option),
(16, payment_metadata.as_ref().map(|m| WithoutLength(m)), option)
(16, payment_metadata.as_ref().map(|m| WithoutLength(m)), option),
(20, trampoline_packet, option)
}, custom_tlvs.iter());
},
Self::BlindedForward { encrypted_tlvs, intro_node_blinding_point } => {
Expand Down Expand Up @@ -4376,12 +4375,12 @@ mod tests {
};
let encoded_payload = msg.encode();

let trampoline_type_bytes = &encoded_payload[19..=23];
let trampoline_type_bytes = &encoded_payload[19..=19];
let mut trampoline_type_cursor = Cursor::new(trampoline_type_bytes);
let trampoline_type_big_size: BigSize = Readable::read(&mut trampoline_type_cursor).unwrap();
assert_eq!(trampoline_type_big_size.0, 66100);
assert_eq!(trampoline_type_big_size.0, 20);

let trampoline_length_bytes = &encoded_payload[24..=26];
let trampoline_length_bytes = &encoded_payload[20..=22];
let mut trampoline_length_cursor = Cursor::new(trampoline_length_bytes);
let trampoline_length_big_size: BigSize = Readable::read(&mut trampoline_length_cursor).unwrap();
assert_eq!(trampoline_length_big_size.0, encoded_trampoline_packet.len() as u64);
Expand Down

0 comments on commit 4021400

Please sign in to comment.