@@ -3771,19 +3771,19 @@ where
37713771
37723772	#[cfg(test)]
37733773	pub fn create_and_insert_outbound_scid_alias_for_test(&self) -> u64 {
3774- 		self.create_and_insert_outbound_scid_alias( )
3774+ 		self.create_and_insert_outbound_scid_alias_with_namespace(fake_scid::Namespace::OutboundAlias )
37753775	}
37763776
37773777	#[rustfmt::skip]
3778- 	fn create_and_insert_outbound_scid_alias (&self) -> u64 {
3778+ 	fn create_and_insert_outbound_scid_alias_with_namespace (&self, namespace: fake_scid::Namespace ) -> u64 {
37793779		let height = self.best_block.read().unwrap().height;
37803780		let mut outbound_scid_alias = 0;
37813781		let mut i = 0;
37823782		loop {
37833783			if cfg!(fuzzing) { // fuzzing chacha20 doesn't use the key at all so we always get the same alias
37843784				outbound_scid_alias += 1;
37853785			} else {
3786- 				outbound_scid_alias = fake_scid::Namespace::OutboundAlias .get_fake_scid(height, &self.chain_hash, &self.fake_scid_rand_bytes, &self.entropy_source);
3786+ 				outbound_scid_alias = namespace .get_fake_scid(height, &self.chain_hash, &self.fake_scid_rand_bytes, &self.entropy_source);
37873787			}
37883788			if outbound_scid_alias != 0 && self.outbound_scid_aliases.lock().unwrap().insert(outbound_scid_alias) {
37893789				break;
@@ -3794,6 +3794,11 @@ where
37943794		outbound_scid_alias
37953795	}
37963796
3797+ 	/// Determines the appropriate outbound SCID namespace based on the intercept_htlcs_on_channel configuration.
3798+ 	fn get_outbound_scid_namespace(intercept_htlcs_on_channel: bool) -> fake_scid::Namespace {
3799+ 		if intercept_htlcs_on_channel { fake_scid::Namespace::Intercept } else { fake_scid::Namespace::OutboundAlias }
3800+ 	}
3801+ 
37973802	/// Creates a new outbound channel to the given remote node and with the given value.
37983803	///
37993804	/// `user_channel_id` will be provided back as in
@@ -3850,9 +3855,10 @@ where
38503855		}
38513856
38523857		let mut channel = {
3853- 			let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
3854- 			let their_features = &peer_state.latest_features;
38553858			let config = if override_config.is_some() { override_config.as_ref().unwrap() } else { &self.default_configuration };
3859+ 			let outbound_scid_namespace = Self::get_outbound_scid_namespace(config.channel_handshake_config.intercept_htlcs_on_channel);
3860+ 			let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_namespace(outbound_scid_namespace);
3861+ 			let their_features = &peer_state.latest_features;
38563862			match OutboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider, their_network_key,
38573863				their_features, channel_value_satoshis, push_msat, user_channel_id, config,
38583864				self.best_block.read().unwrap().height, outbound_scid_alias, temporary_channel_id, &*self.logger)
@@ -8191,7 +8197,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
81918197		}
81928198
81938199		// Now that we know we have a channel, assign an outbound SCID alias.
8194- 		let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
8200+ 		let outbound_scid_namespace = Self::get_outbound_scid_namespace(config.channel_handshake_config.intercept_htlcs_on_channel);
8201+ 		let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_namespace(outbound_scid_namespace);
81958202		channel.context_mut().set_outbound_scid_alias(outbound_scid_alias);
81968203
81978204		if let Some(message_send_event) = message_send_event {
@@ -8407,7 +8414,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
84078414			},
84088415		};
84098416
8410- 		let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
8417+ 		let outbound_scid_namespace = Self::get_outbound_scid_namespace(self.default_configuration.channel_handshake_config.intercept_htlcs_on_channel);
8418+ 		let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_namespace(outbound_scid_namespace);
84118419		channel.context_mut().set_outbound_scid_alias(outbound_scid_alias);
84128420
84138421		if let Some(message_send_event) = message_send_event {
@@ -16303,6 +16311,7 @@ mod tests {
1630316311				to_self_delay: Some(200),
1630416312				max_accepted_htlcs: Some(5),
1630516313				channel_reserve_proportional_millionths: Some(20000),
16314+ 				intercept_htlcs_on_channel: None,
1630616315			}),
1630716316			update_overrides: None,
1630816317		};
0 commit comments