@@ -653,6 +653,7 @@ impl SentHTLCId {
653
653
short_channel_id: hop_data.short_channel_id,
654
654
htlc_id: hop_data.htlc_id,
655
655
},
656
+ HTLCSource::TrampolineForward { .. } => todo!(),
656
657
HTLCSource::OutboundRoute { session_priv, .. } => {
657
658
Self::OutboundRoute { session_priv: session_priv.secret_bytes() }
658
659
},
@@ -676,13 +677,25 @@ type PerSourcePendingForward =
676
677
type FailedHTLCForward = (HTLCSource, PaymentHash, HTLCFailReason, HTLCHandlingFailureType);
677
678
678
679
mod fuzzy_channelmanager {
680
+ use crate::routing::router::RouteHop;
681
+
679
682
use super::*;
680
683
681
684
/// Tracks the inbound corresponding to an outbound HTLC
682
685
#[allow(clippy::derive_hash_xor_eq)] // Our Hash is faithful to the data, we just don't have SecretKey::hash
683
686
#[derive(Clone, Debug, PartialEq, Eq)]
684
687
pub enum HTLCSource {
685
688
PreviousHopData(HTLCPreviousHopData),
689
+ TrampolineForward {
690
+ /// We might be forwarding an incoming payment that was received over MPP, and therefore
691
+ /// need to store the vector of corresponding `HTLCPreviousHopId` values.
692
+ previous_hop_data: Vec<HTLCPreviousHopData>,
693
+ incoming_trampoline_shared_secret: [u8; 32],
694
+ hops: Vec<RouteHop>,
695
+ /// In order to decode inter-Trampoline errors, we need to store the session_priv key
696
+ /// given we're effectively creating new outbound routes.
697
+ session_priv: SecretKey,
698
+ },
686
699
OutboundRoute {
687
700
path: Path,
688
701
session_priv: SecretKey,
@@ -745,6 +758,18 @@ impl core::hash::Hash for HTLCSource {
745
758
first_hop_htlc_msat.hash(hasher);
746
759
bolt12_invoice.hash(hasher);
747
760
},
761
+ HTLCSource::TrampolineForward {
762
+ previous_hop_data,
763
+ incoming_trampoline_shared_secret,
764
+ hops,
765
+ session_priv,
766
+ } => {
767
+ 2u8.hash(hasher);
768
+ previous_hop_data.hash(hasher);
769
+ incoming_trampoline_shared_secret.hash(hasher);
770
+ hops.hash(hasher);
771
+ session_priv[..].hash(hasher);
772
+ },
748
773
}
749
774
}
750
775
}
@@ -7944,6 +7969,7 @@ where
7944
7969
None,
7945
7970
));
7946
7971
},
7972
+ HTLCSource::TrampolineForward { .. } => todo!(),
7947
7973
}
7948
7974
}
7949
7975
@@ -8661,6 +8687,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8661
8687
},
8662
8688
);
8663
8689
},
8690
+ HTLCSource::TrampolineForward { .. } => todo!(),
8664
8691
}
8665
8692
}
8666
8693
@@ -14952,6 +14979,24 @@ impl Readable for HTLCSource {
14952
14979
})
14953
14980
}
14954
14981
1 => Ok(HTLCSource::PreviousHopData(Readable::read(reader)?)),
14982
+ 2 => {
14983
+ let mut previous_hop_data = Vec::new();
14984
+ let mut incoming_trampoline_shared_secret: crate::util::ser::RequiredWrapper<[u8; 32]> = crate::util::ser::RequiredWrapper(None);
14985
+ let mut session_priv: crate::util::ser::RequiredWrapper<SecretKey> = crate::util::ser::RequiredWrapper(None);
14986
+ let mut hops = Vec::new();
14987
+ read_tlv_fields!(reader, {
14988
+ (0, previous_hop_data, required_vec),
14989
+ (2, incoming_trampoline_shared_secret, required),
14990
+ (4, session_priv, required),
14991
+ (6, hops, required_vec),
14992
+ });
14993
+ Ok(HTLCSource::TrampolineForward {
14994
+ previous_hop_data,
14995
+ incoming_trampoline_shared_secret: incoming_trampoline_shared_secret.0.unwrap(),
14996
+ hops,
14997
+ session_priv: session_priv.0.unwrap(),
14998
+ })
14999
+ },
14955
15000
_ => Err(DecodeError::UnknownRequiredFeature),
14956
15001
}
14957
15002
}
@@ -14984,6 +15029,22 @@ impl Writeable for HTLCSource {
14984
15029
1u8.write(writer)?;
14985
15030
field.write(writer)?;
14986
15031
},
15032
+ HTLCSource::TrampolineForward {
15033
+ previous_hop_data: previous_hop_data_ref,
15034
+ ref incoming_trampoline_shared_secret,
15035
+ ref session_priv,
15036
+ hops: hops_ref,
15037
+ } => {
15038
+ 2u8.write(writer)?;
15039
+ let previous_hop_data = previous_hop_data_ref.clone();
15040
+ let hops = hops_ref.clone();
15041
+ write_tlv_fields!(writer, {
15042
+ (0, previous_hop_data, required_vec),
15043
+ (2, incoming_trampoline_shared_secret, required),
15044
+ (4, session_priv, required),
15045
+ (6, hops, required_vec),
15046
+ });
15047
+ },
14987
15048
}
14988
15049
Ok(())
14989
15050
}
@@ -16427,6 +16488,7 @@ where
16427
16488
} else { true }
16428
16489
});
16429
16490
},
16491
+ HTLCSource::TrampolineForward { .. } => todo!(),
16430
16492
HTLCSource::OutboundRoute {
16431
16493
payment_id,
16432
16494
session_priv,
0 commit comments