Skip to content

Commit 960d532

Browse files
committed
Add TrampolineForward variant to PendingHTLCRouting
1 parent a94126b commit 960d532

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

lightning/src/ln/channelmanager.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub use crate::ln::outbound_payment::{Bolt12PaymentError, ProbeSendFailure, Retr
132132
#[cfg(test)]
133133
pub(crate) use crate::ln::outbound_payment::PaymentSendFailure;
134134
use crate::ln::script::ShutdownScript;
135-
135+
use crate::routing::gossip::NodeId;
136136
// We hold various information about HTLC relay in the HTLC objects in Channel itself:
137137
//
138138
// 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 {
170170
/// The absolute CLTV of the inbound HTLC
171171
incoming_cltv_expiry: Option<u32>,
172172
},
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+
173192
/// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
174193
///
175194
/// Note that at this point, we have not checked that the invoice being paid was actually
@@ -278,6 +297,7 @@ impl PendingHTLCRouting {
278297
fn incoming_cltv_expiry(&self) -> Option<u32> {
279298
match self {
280299
Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
300+
Self::TrampolineForward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
281301
Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
282302
Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
283303
}
@@ -8857,6 +8877,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
88578877
for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
88588878
let scid = match forward_info.routing {
88598879
PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8880+
PendingHTLCRouting::TrampolineForward { .. } => 0,
88608881
PendingHTLCRouting::Receive { .. } => 0,
88618882
PendingHTLCRouting::ReceiveKeysend { .. } => 0,
88628883
};
@@ -12397,6 +12418,13 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
1239712418
(7, has_recipient_created_payment_secret, (default_value, false)),
1239812419
(9, payment_context, option),
1239912420
},
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+
}
1240012428
);
1240112429

1240212430
impl_writeable_tlv_based!(PendingHTLCInfo, {

0 commit comments

Comments
 (0)