@@ -132,7 +132,7 @@ pub use crate::ln::outbound_payment::{Bolt12PaymentError, ProbeSendFailure, Retr
132
132
#[cfg(test)]
133
133
pub(crate) use crate::ln::outbound_payment::PaymentSendFailure;
134
134
use crate::ln::script::ShutdownScript;
135
-
135
+ use crate::routing::gossip::NodeId;
136
136
// We hold various information about HTLC relay in the HTLC objects in Channel itself:
137
137
//
138
138
// Upon receipt of an HTLC from a peer, we'll give it a PendingHTLCStatus indicating if it should
@@ -170,6 +170,25 @@ pub enum PendingHTLCRouting {
170
170
/// The absolute CLTV of the inbound HTLC
171
171
incoming_cltv_expiry: Option<u32>,
172
172
},
173
+
174
+ /// An HTLC which should be forwarded on to another Trampoline node.
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, // This should be NonZero<u64> eventually when we bump MSRV
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: Option<u32>,
190
+ },
191
+
173
192
/// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
174
193
///
175
194
/// Note that at this point, we have not checked that the invoice being paid was actually
@@ -278,6 +297,7 @@ impl PendingHTLCRouting {
278
297
fn incoming_cltv_expiry(&self) -> Option<u32> {
279
298
match self {
280
299
Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
300
+ Self::TrampolineForward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
281
301
Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
282
302
Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
283
303
}
@@ -8857,6 +8877,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8857
8877
for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
8858
8878
let scid = match forward_info.routing {
8859
8879
PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8880
+ PendingHTLCRouting::TrampolineForward { .. } => 0,
8860
8881
PendingHTLCRouting::Receive { .. } => 0,
8861
8882
PendingHTLCRouting::ReceiveKeysend { .. } => 0,
8862
8883
};
@@ -12397,6 +12418,13 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12397
12418
(7, has_recipient_created_payment_secret, (default_value, false)),
12398
12419
(9, payment_context, option),
12399
12420
},
12421
+ (3, TrampolineForward) => {
12422
+ (0, incoming_shared_secret, required),
12423
+ (1, onion_packet, required),
12424
+ (2, blinded, option),
12425
+ (3, node_id, required),
12426
+ (4, incoming_cltv_expiry, option),
12427
+ }
12400
12428
);
12401
12429
12402
12430
impl_writeable_tlv_based!(PendingHTLCInfo, {
0 commit comments