@@ -55,6 +55,8 @@ 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+ #[cfg(trampoline)]
59+ use crate::routing::gossip::NodeId;
5860use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
5961use 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};
6062use crate::ln::msgs;
@@ -168,6 +170,24 @@ pub enum PendingHTLCRouting {
168170 /// The absolute CLTV of the inbound HTLC
169171 incoming_cltv_expiry: Option<u32>,
170172 },
173+ /// An HTLC which should be forwarded on to another Trampoline node.
174+ #[cfg(trampoline)]
175+ TrampolineForward {
176+ /// The onion shared secret we build with the sender (or the preceding Trampoline node) used
177+ /// to decrypt the onion.
178+ ///
179+ /// This is later used to encrypt failure packets in the event that the HTLC is failed.
180+ incoming_shared_secret: [u8; 32],
181+ /// The onion which should be included in the forwarded HTLC, telling the next hop what to
182+ /// do with the HTLC.
183+ onion_packet: msgs::TrampolineOnionPacket,
184+ /// The node ID of the Trampoline node which we need to route this HTLC to.
185+ node_id: NodeId,
186+ /// Set if this HTLC is being forwarded within a blinded path.
187+ blinded: Option<BlindedForward>,
188+ /// The absolute CLTV of the inbound HTLC
189+ incoming_cltv_expiry: u32,
190+ },
171191 /// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
172192 ///
173193 /// Note that at this point, we have not checked that the invoice being paid was actually
@@ -269,6 +289,8 @@ impl PendingHTLCRouting {
269289 fn blinded_failure(&self) -> Option<BlindedFailure> {
270290 match self {
271291 Self::Forward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
292+ #[cfg(trampoline)]
293+ Self::TrampolineForward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
272294 Self::Receive { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
273295 Self::ReceiveKeysend { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
274296 _ => None,
@@ -278,6 +300,8 @@ impl PendingHTLCRouting {
278300 fn incoming_cltv_expiry(&self) -> Option<u32> {
279301 match self {
280302 Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
303+ #[cfg(trampoline)]
304+ Self::TrampolineForward { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
281305 Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
282306 Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
283307 }
@@ -8908,6 +8932,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
89088932 for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
89098933 let scid = match forward_info.routing {
89108934 PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8935+ #[cfg(trampoline)]
8936+ PendingHTLCRouting::TrampolineForward { .. } => 0,
89118937 PendingHTLCRouting::Receive { .. } => 0,
89128938 PendingHTLCRouting::ReceiveKeysend { .. } => 0,
89138939 };
@@ -12448,6 +12474,7 @@ impl_writeable_tlv_based!(BlindedForward, {
1244812474 (3, next_blinding_override, option),
1244912475});
1245012476
12477+ #[cfg(not(trampoline))]
1245112478impl_writeable_tlv_based_enum!(PendingHTLCRouting,
1245212479 (0, Forward) => {
1245312480 (0, onion_packet, required),
@@ -12476,6 +12503,42 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
1247612503 (11, invoice_request, option),
1247712504 },
1247812505);
12506+ #[cfg(trampoline)]
12507+ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12508+ (0, Forward) => {
12509+ (0, onion_packet, required),
12510+ (1, blinded, option),
12511+ (2, short_channel_id, required),
12512+ (3, incoming_cltv_expiry, option),
12513+ },
12514+ (1, Receive) => {
12515+ (0, payment_data, required),
12516+ (1, phantom_shared_secret, option),
12517+ (2, incoming_cltv_expiry, required),
12518+ (3, payment_metadata, option),
12519+ (5, custom_tlvs, optional_vec),
12520+ (7, requires_blinded_error, (default_value, false)),
12521+ (9, payment_context, option),
12522+ },
12523+ (2, ReceiveKeysend) => {
12524+ (0, payment_preimage, required),
12525+ (1, requires_blinded_error, (default_value, false)),
12526+ (2, incoming_cltv_expiry, required),
12527+ (3, payment_metadata, option),
12528+ (4, payment_data, option), // Added in 0.0.116
12529+ (5, custom_tlvs, optional_vec),
12530+ (7, has_recipient_created_payment_secret, (default_value, false)),
12531+ (9, payment_context, option),
12532+ (11, invoice_request, option),
12533+ },
12534+ (3, TrampolineForward) => {
12535+ (0, incoming_shared_secret, required),
12536+ (2, onion_packet, required),
12537+ (4, blinded, option),
12538+ (6, node_id, required),
12539+ (8, incoming_cltv_expiry, required),
12540+ }
12541+ );
1247912542
1248012543impl_writeable_tlv_based!(PendingHTLCInfo, {
1248112544 (0, routing, required),
0 commit comments