@@ -58,7 +58,7 @@ use crate::types::features::Bolt11InvoiceFeatures;
58
58
#[cfg(trampoline)]
59
59
use crate::routing::gossip::NodeId;
60
60
use 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};
62
62
use crate::ln::msgs;
63
63
use crate::ln::onion_utils;
64
64
use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
@@ -4290,11 +4290,15 @@ where
4290
4290
// we don't allow forwards outbound over them.
4291
4291
return Err(("Refusing to forward to a private channel based on our config.", 0x4000 | 10));
4292
4292
}
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));
4298
4302
}
4299
4303
4300
4304
// Note that we could technically not return an error yet here and just hope
@@ -4346,7 +4350,13 @@ where
4346
4350
fn can_forward_htlc(
4347
4351
&self, msg: &msgs::UpdateAddHTLC, next_packet_details: &NextPacketDetails
4348
4352
) -> 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>| {
4350
4360
self.can_forward_htlc_to_outgoing_channel(chan, msg, next_packet_details)
4351
4361
}) {
4352
4362
Some(Ok(())) => {},
@@ -4355,8 +4365,8 @@ where
4355
4365
// If we couldn't find the channel info for the scid, it may be a phantom or
4356
4366
// intercept forward.
4357
4367
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)
4360
4370
{} else {
4361
4371
return Err(("Don't have available channel for forwarding as requested.", 0x4000 | 10));
4362
4372
}
@@ -5707,7 +5717,12 @@ where
5707
5717
};
5708
5718
5709
5719
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
+ });
5711
5726
let shared_secret = next_hop.shared_secret().secret_bytes();
5712
5727
5713
5728
// Process the HTLC on the incoming channel.
0 commit comments