@@ -55,6 +55,8 @@ 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
+ #[cfg(trampoline)]
59
+ use crate::routing::gossip::NodeId;
58
60
use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
59
61
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
62
use crate::ln::msgs;
@@ -169,6 +171,24 @@ pub enum PendingHTLCRouting {
169
171
/// The absolute CLTV of the inbound HTLC
170
172
incoming_cltv_expiry: Option<u32>,
171
173
},
174
+ /// An HTLC which should be forwarded on to another Trampoline node.
175
+ #[cfg(trampoline)]
176
+ TrampolineForward {
177
+ /// The onion shared secret we build with the sender (or the preceding Trampoline node) used
178
+ /// to decrypt the onion.
179
+ ///
180
+ /// This is later used to encrypt failure packets in the event that the HTLC is failed.
181
+ incoming_shared_secret: [u8; 32],
182
+ /// The onion which should be included in the forwarded HTLC, telling the next hop what to
183
+ /// do with the HTLC.
184
+ onion_packet: msgs::TrampolineOnionPacket,
185
+ /// The node ID of the Trampoline node which we need to route this HTLC to.
186
+ node_id: NodeId,
187
+ /// Set if this HTLC is being forwarded within a blinded path.
188
+ blinded: Option<BlindedForward>,
189
+ /// The absolute CLTV of the inbound HTLC
190
+ incoming_cltv_expiry: u32,
191
+ },
172
192
/// The onion indicates that this is a payment for an invoice (supposedly) generated by us.
173
193
///
174
194
/// Note that at this point, we have not checked that the invoice being paid was actually
@@ -270,6 +290,8 @@ impl PendingHTLCRouting {
270
290
fn blinded_failure(&self) -> Option<BlindedFailure> {
271
291
match self {
272
292
Self::Forward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
293
+ #[cfg(trampoline)]
294
+ Self::TrampolineForward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
273
295
Self::Receive { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
274
296
Self::ReceiveKeysend { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
275
297
_ => None,
@@ -279,6 +301,8 @@ impl PendingHTLCRouting {
279
301
fn incoming_cltv_expiry(&self) -> Option<u32> {
280
302
match self {
281
303
Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
304
+ #[cfg(trampoline)]
305
+ Self::TrampolineForward { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
282
306
Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
283
307
Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
284
308
}
@@ -8909,6 +8933,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8909
8933
for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
8910
8934
let scid = match forward_info.routing {
8911
8935
PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8936
+ #[cfg(trampoline)]
8937
+ PendingHTLCRouting::TrampolineForward { .. } => 0,
8912
8938
PendingHTLCRouting::Receive { .. } => 0,
8913
8939
PendingHTLCRouting::ReceiveKeysend { .. } => 0,
8914
8940
};
@@ -12449,6 +12475,7 @@ impl_writeable_tlv_based!(BlindedForward, {
12449
12475
(3, next_blinding_override, option),
12450
12476
});
12451
12477
12478
+ #[cfg(not(trampoline))]
12452
12479
impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12453
12480
(0, Forward) => {
12454
12481
(0, onion_packet, required),
@@ -12477,6 +12504,42 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12477
12504
(11, invoice_request, option),
12478
12505
},
12479
12506
);
12507
+ #[cfg(trampoline)]
12508
+ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12509
+ (0, Forward) => {
12510
+ (0, onion_packet, required),
12511
+ (1, blinded, option),
12512
+ (2, short_channel_id, required),
12513
+ (3, incoming_cltv_expiry, option),
12514
+ },
12515
+ (1, Receive) => {
12516
+ (0, payment_data, required),
12517
+ (1, phantom_shared_secret, option),
12518
+ (2, incoming_cltv_expiry, required),
12519
+ (3, payment_metadata, option),
12520
+ (5, custom_tlvs, optional_vec),
12521
+ (7, requires_blinded_error, (default_value, false)),
12522
+ (9, payment_context, option),
12523
+ },
12524
+ (2, ReceiveKeysend) => {
12525
+ (0, payment_preimage, required),
12526
+ (1, requires_blinded_error, (default_value, false)),
12527
+ (2, incoming_cltv_expiry, required),
12528
+ (3, payment_metadata, option),
12529
+ (4, payment_data, option), // Added in 0.0.116
12530
+ (5, custom_tlvs, optional_vec),
12531
+ (7, has_recipient_created_payment_secret, (default_value, false)),
12532
+ (9, payment_context, option),
12533
+ (11, invoice_request, option),
12534
+ },
12535
+ (3, TrampolineForward) => {
12536
+ (0, incoming_shared_secret, required),
12537
+ (2, onion_packet, required),
12538
+ (4, blinded, option),
12539
+ (6, node_id, required),
12540
+ (8, incoming_cltv_expiry, required),
12541
+ }
12542
+ );
12480
12543
12481
12544
impl_writeable_tlv_based!(PendingHTLCInfo, {
12482
12545
(0, routing, required),
0 commit comments