@@ -646,6 +646,7 @@ impl SentHTLCId {
646646 short_channel_id: hop_data.short_channel_id,
647647 htlc_id: hop_data.htlc_id,
648648 },
649+ HTLCSource::TrampolineForward { .. } => todo!(),
649650 HTLCSource::OutboundRoute { session_priv, .. } => {
650651 Self::OutboundRoute { session_priv: session_priv.secret_bytes() }
651652 },
@@ -669,13 +670,25 @@ type PerSourcePendingForward =
669670type FailedHTLCForward = (HTLCSource, PaymentHash, HTLCFailReason, HTLCHandlingFailureType);
670671
671672mod fuzzy_channelmanager {
673+ use crate::routing::router::RouteHop;
674+
672675 use super::*;
673676
674677 /// Tracks the inbound corresponding to an outbound HTLC
675678 #[allow(clippy::derive_hash_xor_eq)] // Our Hash is faithful to the data, we just don't have SecretKey::hash
676679 #[derive(Clone, Debug, PartialEq, Eq)]
677680 pub enum HTLCSource {
678681 PreviousHopData(HTLCPreviousHopData),
682+ TrampolineForward {
683+ /// We might be forwarding an incoming payment that was received over MPP, and therefore
684+ /// need to store the vector of corresponding `HTLCPreviousHopId` values.
685+ previous_hop_data: Vec<HTLCPreviousHopData>,
686+ incoming_trampoline_shared_secret: [u8; 32],
687+ hops: Vec<RouteHop>,
688+ /// In order to decode inter-Trampoline errors, we need to store the session_priv key
689+ /// given we're effectively creating new outbound routes.
690+ session_priv: SecretKey,
691+ },
679692 OutboundRoute {
680693 path: Path,
681694 session_priv: SecretKey,
@@ -738,6 +751,18 @@ impl core::hash::Hash for HTLCSource {
738751 first_hop_htlc_msat.hash(hasher);
739752 bolt12_invoice.hash(hasher);
740753 },
754+ HTLCSource::TrampolineForward {
755+ previous_hop_data,
756+ incoming_trampoline_shared_secret,
757+ hops,
758+ session_priv,
759+ } => {
760+ 2u8.hash(hasher);
761+ previous_hop_data.hash(hasher);
762+ incoming_trampoline_shared_secret.hash(hasher);
763+ hops.hash(hasher);
764+ session_priv[..].hash(hasher);
765+ },
741766 }
742767 }
743768}
@@ -8050,6 +8075,7 @@ where
80508075 None,
80518076 ));
80528077 },
8078+ HTLCSource::TrampolineForward { .. } => todo!(),
80538079 }
80548080 }
80558081
@@ -8767,6 +8793,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
87678793 },
87688794 );
87698795 },
8796+ HTLCSource::TrampolineForward { .. } => todo!(),
87708797 }
87718798 }
87728799
@@ -15064,6 +15091,24 @@ impl Readable for HTLCSource {
1506415091 })
1506515092 }
1506615093 1 => Ok(HTLCSource::PreviousHopData(Readable::read(reader)?)),
15094+ 2 => {
15095+ let mut previous_hop_data = Vec::new();
15096+ let mut incoming_trampoline_shared_secret: crate::util::ser::RequiredWrapper<[u8; 32]> = crate::util::ser::RequiredWrapper(None);
15097+ let mut session_priv: crate::util::ser::RequiredWrapper<SecretKey> = crate::util::ser::RequiredWrapper(None);
15098+ let mut hops = Vec::new();
15099+ read_tlv_fields!(reader, {
15100+ (0, previous_hop_data, required_vec),
15101+ (2, incoming_trampoline_shared_secret, required),
15102+ (4, session_priv, required),
15103+ (6, hops, required_vec),
15104+ });
15105+ Ok(HTLCSource::TrampolineForward {
15106+ previous_hop_data,
15107+ incoming_trampoline_shared_secret: incoming_trampoline_shared_secret.0.unwrap(),
15108+ hops,
15109+ session_priv: session_priv.0.unwrap(),
15110+ })
15111+ },
1506715112 _ => Err(DecodeError::UnknownRequiredFeature),
1506815113 }
1506915114 }
@@ -15096,6 +15141,22 @@ impl Writeable for HTLCSource {
1509615141 1u8.write(writer)?;
1509715142 field.write(writer)?;
1509815143 },
15144+ HTLCSource::TrampolineForward {
15145+ previous_hop_data: previous_hop_data_ref,
15146+ ref incoming_trampoline_shared_secret,
15147+ ref session_priv,
15148+ hops: hops_ref,
15149+ } => {
15150+ 2u8.write(writer)?;
15151+ let previous_hop_data = previous_hop_data_ref.clone();
15152+ let hops = hops_ref.clone();
15153+ write_tlv_fields!(writer, {
15154+ (0, previous_hop_data, required_vec),
15155+ (2, incoming_trampoline_shared_secret, required),
15156+ (4, session_priv, required),
15157+ (6, hops, required_vec),
15158+ });
15159+ },
1509915160 }
1510015161 Ok(())
1510115162 }
@@ -16539,6 +16600,7 @@ where
1653916600 } else { true }
1654016601 });
1654116602 },
16603+ HTLCSource::TrampolineForward { .. } => todo!(),
1654216604 HTLCSource::OutboundRoute {
1654316605 payment_id,
1654416606 session_priv,
0 commit comments