@@ -131,7 +131,7 @@ pub use crate::ln::outbound_payment::{Bolt12PaymentError, ProbeSendFailure, Retr
131
131
#[cfg(test)]
132
132
pub(crate) use crate::ln::outbound_payment::PaymentSendFailure;
133
133
use crate::ln::script::ShutdownScript;
134
-
134
+ use crate::routing::gossip::NodeId;
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,25 @@ pub enum PendingHTLCRouting {
169
169
/// The absolute CLTV of the inbound HTLC
170
170
incoming_cltv_expiry: Option<u32>,
171
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, // This should be NonZero<u64> eventually when we bump MSRV
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: Option<u32>,
189
+ },
190
+
172
191
/// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
173
192
///
174
193
/// Note that at this point, we have not checked that the invoice being paid was actually
@@ -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, .. } => *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
+ (1, onion_packet, required),
12503
+ (2, blinded, option),
12504
+ (3, node_id, required),
12505
+ (4, incoming_cltv_expiry, option),
12506
+ }
12479
12507
);
12480
12508
12481
12509
impl_writeable_tlv_based!(PendingHTLCInfo, {
0 commit comments