@@ -58,7 +58,7 @@ use crate::types::features::Bolt11InvoiceFeatures;
5858#[cfg(trampoline)]
5959use crate::routing::gossip::NodeId;
6060use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, RouteParametersConfig, Router};
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};
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, HopConnector, InboundHTLCErr, NextPacketDetails};
6262use crate::ln::msgs;
6363use crate::ln::onion_utils;
6464use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
@@ -4290,11 +4290,15 @@ where
42904290 // we don't allow forwards outbound over them.
42914291 return Err(("Refusing to forward to a private channel based on our config.", 0x4000 | 10));
42924292 }
4293- if chan.context.get_channel_type().supports_scid_privacy() && next_packet.outgoing_scid != chan.context.outbound_scid_alias() {
4294- // `option_scid_alias` (referred to in LDK as `scid_privacy`) means
4295- // "refuse to forward unless the SCID alias was used", so we pretend
4296- // we don't have the channel here.
4297- return Err(("Refusing to forward over real channel SCID as our counterparty requested.", 0x4000 | 10));
4293+ if let HopConnector::ShortChannelId(outgoing_scid) = next_packet.outgoing_connector {
4294+ if chan.context.get_channel_type().supports_scid_privacy() && outgoing_scid != chan.context.outbound_scid_alias() {
4295+ // `option_scid_alias` (referred to in LDK as `scid_privacy`) means
4296+ // "refuse to forward unless the SCID alias was used", so we pretend
4297+ // we don't have the channel here.
4298+ return Err(("Refusing to forward over real channel SCID as our counterparty requested.", 0x4000 | 10));
4299+ }
4300+ } else {
4301+ return Err(("Cannot forward by Node ID without SCID.", 0x4000 | 10));
42984302 }
42994303
43004304 // Note that we could technically not return an error yet here and just hope
@@ -4346,7 +4350,13 @@ where
43464350 fn can_forward_htlc(
43474351 &self, msg: &msgs::UpdateAddHTLC, next_packet_details: &NextPacketDetails
43484352 ) -> Result<(), (&'static str, u16)> {
4349- match self.do_funded_channel_callback(next_packet_details.outgoing_scid, |chan: &mut FundedChannel<SP>| {
4353+ let outgoing_scid = match next_packet_details.outgoing_connector {
4354+ HopConnector::ShortChannelId(scid) => scid,
4355+ HopConnector::Trampoline(_) => {
4356+ return Err(("Cannot forward by Node ID without SCID.", 0x4000 | 10));
4357+ }
4358+ };
4359+ match self.do_funded_channel_callback(outgoing_scid, |chan: &mut FundedChannel<SP>| {
43504360 self.can_forward_htlc_to_outgoing_channel(chan, msg, next_packet_details)
43514361 }) {
43524362 Some(Ok(())) => {},
@@ -4355,8 +4365,8 @@ where
43554365 // If we couldn't find the channel info for the scid, it may be a phantom or
43564366 // intercept forward.
43574367 if (self.default_configuration.accept_intercept_htlcs &&
4358- fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, next_packet_details. outgoing_scid, &self.chain_hash)) ||
4359- fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, next_packet_details. outgoing_scid, &self.chain_hash)
4368+ fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)) ||
4369+ fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)
43604370 {} else {
43614371 return Err(("Don't have available channel for forwarding as requested.", 0x4000 | 10));
43624372 }
@@ -5707,7 +5717,12 @@ where
57075717 };
57085718
57095719 let is_intro_node_blinded_forward = next_hop.is_intro_node_blinded_forward();
5710- let outgoing_scid_opt = next_packet_details_opt.as_ref().map(|d| d.outgoing_scid);
5720+ let outgoing_scid_opt = next_packet_details_opt.as_ref().and_then(|d| {
5721+ match d.outgoing_connector {
5722+ HopConnector::ShortChannelId(scid) => { Some(scid) }
5723+ HopConnector::Trampoline(_) => { None }
5724+ }
5725+ });
57115726 let shared_secret = next_hop.shared_secret().secret_bytes();
57125727
57135728 // Process the HTLC on the incoming channel.
0 commit comments