Skip to content

Commit acabd9e

Browse files
committed
f: cfg-gate TrampolineForward
1 parent 56d4647 commit acabd9e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ check-cfg = [
6262
"cfg(ldk_bench)",
6363
"cfg(ldk_test_vectors)",
6464
"cfg(taproot)",
65+
"cfg(trampoline)",
6566
"cfg(require_route_graph_test)",
6667
"cfg(splicing)",
6768
"cfg(async_payments)",

lightning/src/ln/channelmanager.rs

+35
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ use crate::ln::channel_state::ChannelDetails;
5555
use crate::types::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
5656
#[cfg(any(feature = "_test_utils", test))]
5757
use crate::types::features::Bolt11InvoiceFeatures;
58+
#[cfg(taproot)]
5859
use crate::routing::gossip::NodeId;
5960
use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
6061
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};
@@ -171,6 +172,7 @@ pub enum PendingHTLCRouting {
171172
incoming_cltv_expiry: Option<u32>,
172173
},
173174
/// An HTLC which should be forwarded on to another Trampoline node.
175+
#[cfg(trampoline)]
174176
TrampolineForward {
175177
/// The onion shared secret we build with the sender (or the preceding Trampoline node) used
176178
/// to decrypt the onion.
@@ -288,6 +290,7 @@ impl PendingHTLCRouting {
288290
fn blinded_failure(&self) -> Option<BlindedFailure> {
289291
match self {
290292
Self::Forward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
293+
#[cfg(trampoline)]
291294
Self::TrampolineForward { blinded: Some(BlindedForward { failure, .. }), .. } => Some(*failure),
292295
Self::Receive { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
293296
Self::ReceiveKeysend { requires_blinded_error: true, .. } => Some(BlindedFailure::FromBlindedNode),
@@ -298,6 +301,7 @@ impl PendingHTLCRouting {
298301
fn incoming_cltv_expiry(&self) -> Option<u32> {
299302
match self {
300303
Self::Forward { incoming_cltv_expiry, .. } => *incoming_cltv_expiry,
304+
#[cfg(trampoline)]
301305
Self::TrampolineForward { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
302306
Self::Receive { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
303307
Self::ReceiveKeysend { incoming_cltv_expiry, .. } => Some(*incoming_cltv_expiry),
@@ -8929,6 +8933,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
89298933
for (forward_info, prev_htlc_id) in pending_forwards.drain(..) {
89308934
let scid = match forward_info.routing {
89318935
PendingHTLCRouting::Forward { short_channel_id, .. } => short_channel_id,
8936+
#[cfg(trampoline)]
89328937
PendingHTLCRouting::TrampolineForward { .. } => 0,
89338938
PendingHTLCRouting::Receive { .. } => 0,
89348939
PendingHTLCRouting::ReceiveKeysend { .. } => 0,
@@ -12470,6 +12475,36 @@ impl_writeable_tlv_based!(BlindedForward, {
1247012475
(3, next_blinding_override, option),
1247112476
});
1247212477

12478+
#[cfg(not(trampoline))]
12479+
impl_writeable_tlv_based_enum!(PendingHTLCRouting,
12480+
(0, Forward) => {
12481+
(0, onion_packet, required),
12482+
(1, blinded, option),
12483+
(2, short_channel_id, required),
12484+
(3, incoming_cltv_expiry, option),
12485+
},
12486+
(1, Receive) => {
12487+
(0, payment_data, required),
12488+
(1, phantom_shared_secret, option),
12489+
(2, incoming_cltv_expiry, required),
12490+
(3, payment_metadata, option),
12491+
(5, custom_tlvs, optional_vec),
12492+
(7, requires_blinded_error, (default_value, false)),
12493+
(9, payment_context, option),
12494+
},
12495+
(2, ReceiveKeysend) => {
12496+
(0, payment_preimage, required),
12497+
(1, requires_blinded_error, (default_value, false)),
12498+
(2, incoming_cltv_expiry, required),
12499+
(3, payment_metadata, option),
12500+
(4, payment_data, option), // Added in 0.0.116
12501+
(5, custom_tlvs, optional_vec),
12502+
(7, has_recipient_created_payment_secret, (default_value, false)),
12503+
(9, payment_context, option),
12504+
(11, invoice_request, option),
12505+
},
12506+
);
12507+
#[cfg(trampoline)]
1247312508
impl_writeable_tlv_based_enum!(PendingHTLCRouting,
1247412509
(0, Forward) => {
1247512510
(0, onion_packet, required),

0 commit comments

Comments
 (0)