@@ -646,6 +646,7 @@ impl SentHTLCId {
646
646
short_channel_id: hop_data.short_channel_id,
647
647
htlc_id: hop_data.htlc_id,
648
648
},
649
+ HTLCSource::TrampolineForward { .. } => todo!(),
649
650
HTLCSource::OutboundRoute { session_priv, .. } => {
650
651
Self::OutboundRoute { session_priv: session_priv.secret_bytes() }
651
652
},
@@ -669,13 +670,25 @@ type PerSourcePendingForward =
669
670
type FailedHTLCForward = (HTLCSource, PaymentHash, HTLCFailReason, HTLCHandlingFailureType);
670
671
671
672
mod fuzzy_channelmanager {
673
+ use crate::routing::router::RouteHop;
674
+
672
675
use super::*;
673
676
674
677
/// Tracks the inbound corresponding to an outbound HTLC
675
678
#[allow(clippy::derive_hash_xor_eq)] // Our Hash is faithful to the data, we just don't have SecretKey::hash
676
679
#[derive(Clone, Debug, PartialEq, Eq)]
677
680
pub enum HTLCSource {
678
681
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
+ },
679
692
OutboundRoute {
680
693
path: Path,
681
694
session_priv: SecretKey,
@@ -738,6 +751,18 @@ impl core::hash::Hash for HTLCSource {
738
751
first_hop_htlc_msat.hash(hasher);
739
752
bolt12_invoice.hash(hasher);
740
753
},
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
+ },
741
766
}
742
767
}
743
768
}
@@ -8050,6 +8075,7 @@ where
8050
8075
None,
8051
8076
));
8052
8077
},
8078
+ HTLCSource::TrampolineForward { .. } => todo!(),
8053
8079
}
8054
8080
}
8055
8081
@@ -8767,6 +8793,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8767
8793
},
8768
8794
);
8769
8795
},
8796
+ HTLCSource::TrampolineForward { .. } => todo!(),
8770
8797
}
8771
8798
}
8772
8799
@@ -15064,6 +15091,24 @@ impl Readable for HTLCSource {
15064
15091
})
15065
15092
}
15066
15093
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
+ },
15067
15112
_ => Err(DecodeError::UnknownRequiredFeature),
15068
15113
}
15069
15114
}
@@ -15096,6 +15141,22 @@ impl Writeable for HTLCSource {
15096
15141
1u8.write(writer)?;
15097
15142
field.write(writer)?;
15098
15143
},
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
+ },
15099
15160
}
15100
15161
Ok(())
15101
15162
}
@@ -16539,6 +16600,7 @@ where
16539
16600
} else { true }
16540
16601
});
16541
16602
},
16603
+ HTLCSource::TrampolineForward { .. } => todo!(),
16542
16604
HTLCSource::OutboundRoute {
16543
16605
payment_id,
16544
16606
session_priv,
0 commit comments