@@ -57,7 +57,7 @@ use crate::types::features::Bolt11InvoiceFeatures;
57
57
#[cfg(trampoline)]
58
58
use crate::routing::gossip::NodeId;
59
59
use crate::routing::router::{BlindedTail, InFlightHtlcs, Path, Payee, PaymentParameters, RouteParameters, RouteParametersConfig, Router, FixedRouter, Route};
60
- 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
+ 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};
61
61
use crate::ln::msgs;
62
62
use crate::ln::onion_utils;
63
63
use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
@@ -4288,11 +4288,15 @@ where
4288
4288
// we don't allow forwards outbound over them.
4289
4289
return Err(("Refusing to forward to a private channel based on our config.", 0x4000 | 10));
4290
4290
}
4291
- if chan.context.get_channel_type().supports_scid_privacy() && next_packet.outgoing_scid != chan.context.outbound_scid_alias() {
4292
- // `option_scid_alias` (referred to in LDK as `scid_privacy`) means
4293
- // "refuse to forward unless the SCID alias was used", so we pretend
4294
- // we don't have the channel here.
4295
- return Err(("Refusing to forward over real channel SCID as our counterparty requested.", 0x4000 | 10));
4291
+ if let HopConnector::ShortChannelId(outgoing_scid) = next_packet.outgoing_connector {
4292
+ if chan.context.get_channel_type().supports_scid_privacy() && outgoing_scid != chan.context.outbound_scid_alias() {
4293
+ // `option_scid_alias` (referred to in LDK as `scid_privacy`) means
4294
+ // "refuse to forward unless the SCID alias was used", so we pretend
4295
+ // we don't have the channel here.
4296
+ return Err(("Refusing to forward over real channel SCID as our counterparty requested.", 0x4000 | 10));
4297
+ }
4298
+ } else {
4299
+ return Err(("Cannot forward by Node ID without SCID.", 0x4000 | 10));
4296
4300
}
4297
4301
4298
4302
// Note that we could technically not return an error yet here and just hope
@@ -4344,7 +4348,13 @@ where
4344
4348
fn can_forward_htlc(
4345
4349
&self, msg: &msgs::UpdateAddHTLC, next_packet_details: &NextPacketDetails
4346
4350
) -> Result<(), (&'static str, u16)> {
4347
- match self.do_funded_channel_callback(next_packet_details.outgoing_scid, |chan: &mut FundedChannel<SP>| {
4351
+ let outgoing_scid = match next_packet_details.outgoing_connector {
4352
+ HopConnector::ShortChannelId(scid) => scid,
4353
+ HopConnector::Trampoline(_) => {
4354
+ return Err(("Cannot forward by Node ID without SCID.", 0x4000 | 10));
4355
+ }
4356
+ };
4357
+ match self.do_funded_channel_callback(outgoing_scid, |chan: &mut FundedChannel<SP>| {
4348
4358
self.can_forward_htlc_to_outgoing_channel(chan, msg, next_packet_details)
4349
4359
}) {
4350
4360
Some(Ok(())) => {},
@@ -4353,8 +4363,8 @@ where
4353
4363
// If we couldn't find the channel info for the scid, it may be a phantom or
4354
4364
// intercept forward.
4355
4365
if (self.default_configuration.accept_intercept_htlcs &&
4356
- fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, next_packet_details. outgoing_scid, &self.chain_hash)) ||
4357
- fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, next_packet_details. outgoing_scid, &self.chain_hash)
4366
+ fake_scid::is_valid_intercept(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)) ||
4367
+ fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, outgoing_scid, &self.chain_hash)
4358
4368
{} else {
4359
4369
return Err(("Don't have available channel for forwarding as requested.", 0x4000 | 10));
4360
4370
}
@@ -5705,7 +5715,12 @@ where
5705
5715
};
5706
5716
5707
5717
let is_intro_node_blinded_forward = next_hop.is_intro_node_blinded_forward();
5708
- let outgoing_scid_opt = next_packet_details_opt.as_ref().map(|d| d.outgoing_scid);
5718
+ let outgoing_scid_opt = next_packet_details_opt.as_ref().and_then(|d| {
5719
+ match d.outgoing_connector {
5720
+ HopConnector::ShortChannelId(scid) => { Some(scid) }
5721
+ HopConnector::Trampoline(_) => { None }
5722
+ }
5723
+ });
5709
5724
let shared_secret = next_hop.shared_secret().secret_bytes();
5710
5725
5711
5726
// Process the HTLC on the incoming channel.
0 commit comments