@@ -55,6 +55,7 @@ use crate::ln::channel_state::ChannelDetails;
5555use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
5656#[cfg(any(feature = "_test_utils", test))]
5757use crate::types::features::Bolt11InvoiceFeatures;
58+ use crate::routing::gossip::NodeId;
5859use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
5960use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, InboundHTLCErr, NextPacketDetails};
6061use crate::ln::msgs;
@@ -169,6 +170,23 @@ pub enum PendingHTLCRouting {
169170 /// The absolute CLTV of the inbound HTLC
170171 incoming_cltv_expiry: Option<u32>,
171172 },
173+ /// An HTLC which should be forwarded on to another Trampoline node.
174+ TrampolineForward {
175+ /// The onion shared secret we build with the sender (or the preceding Trampoline node) used
176+ /// to decrypt the onion.
177+ ///
178+ /// This is later used to encrypt failure packets in the event that the HTLC is failed.
179+ incoming_shared_secret: [u8; 32],
180+ /// The onion which should be included in the forwarded HTLC, telling the next hop what to
181+ /// do with the HTLC.
182+ onion_packet: msgs::TrampolineOnionPacket,
183+ /// The node ID of the Trampoline node which we need to route this HTLC to.
184+ node_id: NodeId,
185+ /// Set if this HTLC is being forwarded within a blinded path.
186+ blinded: Option<BlindedForward>,
187+ /// The absolute CLTV of the inbound HTLC
188+ incoming_cltv_expiry: u32,
189+ },
172190 /// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
173191 ///
174192 /// Note that at this point, we have not checked that the invoice being paid was actually
@@ -270,6 +288,7 @@ impl PendingHTLCRouting {
270288 fn blinded_failure(&self) -> Option<BlindedFailure> {
271289 match self {
272290 Self::Forward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
291+ Self::TrampolineForward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
273292 Self::Receive { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
274293 Self::ReceiveKeysend { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
275294 _ => None,
@@ -279,6 +298,7 @@ impl PendingHTLCRouting {
279298 fn incoming_cltv_expiry(&self) -> Option<u32> {
280299 match self {
281300 Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
301+ Self::TrampolineForward { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
282302 Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
283303 Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
284304 }
@@ -8909,6 +8929,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
89098929 for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
89108930 let scid = match forward_info.routing {
89118931 PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8932+ PendingHTLCRouting::TrampolineForward { .. } => 0,
89128933 PendingHTLCRouting::Receive { .. } => 0,
89138934 PendingHTLCRouting::ReceiveKeysend { .. } => 0,
89148935 };
@@ -12476,6 +12497,13 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
1247612497 (9, payment_context, option),
1247712498 (11, invoice_request, option),
1247812499 },
12500+ (3, TrampolineForward) => {
12501+ (0, incoming_shared_secret, required),
12502+ (2, onion_packet, required),
12503+ (4, blinded, option),
12504+ (6, node_id, required),
12505+ (8, incoming_cltv_expiry, required),
12506+ }
1247912507);
1248012508
1248112509impl_writeable_tlv_based!(PendingHTLCInfo, {
0 commit comments