@@ -55,6 +55,7 @@ use crate::ln::channel_state::ChannelDetails;
55
55
use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
56
56
#[cfg(any(feature = "_test_utils", test))]
57
57
use crate::types::features::Bolt11InvoiceFeatures;
58
+ use crate::routing::gossip::NodeId;
58
59
use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
59
60
use 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};
60
61
use crate::ln::msgs;
@@ -169,6 +170,23 @@ pub enum PendingHTLCRouting {
169
170
/// The absolute CLTV of the inbound HTLC
170
171
incoming_cltv_expiry: Option<u32>,
171
172
},
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
+ },
172
190
/// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
173
191
///
174
192
/// Note that at this point, we have not checked that the invoice being paid was actually
@@ -270,6 +288,7 @@ impl PendingHTLCRouting {
270
288
fn blinded_failure(&self) -> Option<BlindedFailure> {
271
289
match self {
272
290
Self::Forward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
291
+ Self::TrampolineForward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
273
292
Self::Receive { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
274
293
Self::ReceiveKeysend { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
275
294
_ => None,
@@ -279,6 +298,7 @@ impl PendingHTLCRouting {
279
298
fn incoming_cltv_expiry(&self) -> Option<u32> {
280
299
match self {
281
300
Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
301
+ Self::TrampolineForward { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
282
302
Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
283
303
Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
284
304
}
@@ -8909,6 +8929,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8909
8929
for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
8910
8930
let scid = match forward_info.routing {
8911
8931
PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8932
+ PendingHTLCRouting::TrampolineForward { .. } => 0,
8912
8933
PendingHTLCRouting::Receive { .. } => 0,
8913
8934
PendingHTLCRouting::ReceiveKeysend { .. } => 0,
8914
8935
};
@@ -12476,6 +12497,13 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12476
12497
(9, payment_context, option),
12477
12498
(11, invoice_request, option),
12478
12499
},
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
+ }
12479
12507
);
12480
12508
12481
12509
impl_writeable_tlv_based!(PendingHTLCInfo, {
0 commit comments