@@ -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;
@@ -131,7 +132,6 @@ pub use crate::ln::outbound_payment::{Bolt12PaymentError, ProbeSendFailure, Retr
131
132
#[cfg(test)]
132
133
pub(crate) use crate::ln::outbound_payment::PaymentSendFailure;
133
134
use crate::ln::script::ShutdownScript;
134
-
135
135
// We hold various information about HTLC relay in the HTLC objects in Channel itself:
136
136
//
137
137
// Upon receipt of an HTLC from a peer, we'll give it a PendingHTLCStatus indicating if it should
@@ -169,6 +169,23 @@ pub enum PendingHTLCRouting {
169
169
/// The absolute CLTV of the inbound HTLC
170
170
incoming_cltv_expiry: Option<u32>,
171
171
},
172
+ /// An HTLC which should be forwarded on to another Trampoline node.
173
+ TrampolineForward {
174
+ /// The onion shared secret we build with the sender (or the preceding Trampoline node) used
175
+ /// to decrypt the onion.
176
+ ///
177
+ /// This is later used to encrypt failure packets in the event that the HTLC is failed.
178
+ incoming_shared_secret: [u8; 32],
179
+ /// The onion which should be included in the forwarded HTLC, telling the next hop what to
180
+ /// do with the HTLC.
181
+ onion_packet: msgs::TrampolineOnionPacket,
182
+ /// The node ID of the Trampoline node which we need to route this HTLC to.
183
+ node_id: NodeId,
184
+ /// Set if this HTLC is being forwarded within a blinded path.
185
+ blinded: Option<BlindedForward>,
186
+ /// The absolute CLTV of the inbound HTLC
187
+ incoming_cltv_expiry: u32,
188
+ },
172
189
/// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
173
190
///
174
191
/// Note that at this point, we have not checked that the invoice being paid was actually
@@ -270,6 +287,7 @@ impl PendingHTLCRouting {
270
287
fn blinded_failure(&self) -> Option<BlindedFailure> {
271
288
match self {
272
289
Self::Forward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
290
+ Self::TrampolineForward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
273
291
Self::Receive { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
274
292
Self::ReceiveKeysend { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
275
293
_ => None,
@@ -279,6 +297,7 @@ impl PendingHTLCRouting {
279
297
fn incoming_cltv_expiry(&self) -> Option<u32> {
280
298
match self {
281
299
Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
300
+ Self::TrampolineForward { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
282
301
Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
283
302
Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
284
303
}
@@ -8909,6 +8928,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8909
8928
for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
8910
8929
let scid = match forward_info.routing {
8911
8930
PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8931
+ PendingHTLCRouting::TrampolineForward { .. } => 0,
8912
8932
PendingHTLCRouting::Receive { .. } => 0,
8913
8933
PendingHTLCRouting::ReceiveKeysend { .. } => 0,
8914
8934
};
@@ -12476,6 +12496,13 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12476
12496
(9, payment_context, option),
12477
12497
(11, invoice_request, option),
12478
12498
},
12499
+ (3, TrampolineForward) => {
12500
+ (0, incoming_shared_secret, required),
12501
+ (2, onion_packet, required),
12502
+ (4, blinded, option),
12503
+ (6, node_id, required),
12504
+ (8, incoming_cltv_expiry, option),
12505
+ }
12479
12506
);
12480
12507
12481
12508
impl_writeable_tlv_based!(PendingHTLCInfo, {
0 commit comments