@@ -3776,14 +3776,24 @@ where
37763776
37773777	#[rustfmt::skip]
37783778	fn create_and_insert_outbound_scid_alias(&self) -> u64 {
3779+ 		self.create_and_insert_outbound_scid_alias_with_intercept(false)
3780+ 	}
3781+ 
3782+ 	#[rustfmt::skip]
3783+ 	fn create_and_insert_outbound_scid_alias_with_intercept(&self, use_intercept_namespace: bool) -> u64 {
37793784		let height = self.best_block.read().unwrap().height;
37803785		let mut outbound_scid_alias = 0;
37813786		let mut i = 0;
37823787		loop {
37833788			if cfg!(fuzzing) { // fuzzing chacha20 doesn't use the key at all so we always get the same alias
37843789				outbound_scid_alias += 1;
37853790			} else {
3786- 				outbound_scid_alias = fake_scid::Namespace::OutboundAlias.get_fake_scid(height, &self.chain_hash, &self.fake_scid_rand_bytes, &self.entropy_source);
3791+ 				let namespace = if use_intercept_namespace {
3792+ 					fake_scid::Namespace::Intercept
3793+ 				} else {
3794+ 					fake_scid::Namespace::OutboundAlias
3795+ 				};
3796+ 				outbound_scid_alias = namespace.get_fake_scid(height, &self.chain_hash, &self.fake_scid_rand_bytes, &self.entropy_source);
37873797			}
37883798			if outbound_scid_alias != 0 && self.outbound_scid_aliases.lock().unwrap().insert(outbound_scid_alias) {
37893799				break;
@@ -3850,9 +3860,10 @@ where
38503860		}
38513861
38523862		let mut channel = {
3853- 			let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
3854- 			let their_features = &peer_state.latest_features;
38553863			let config = if override_config.is_some() { override_config.as_ref().unwrap() } else { &self.default_configuration };
3864+ 			let use_intercept_scid = config.channel_handshake_config.intercept_htlcs_on_channel;
3865+ 			let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_intercept(use_intercept_scid);
3866+ 			let their_features = &peer_state.latest_features;
38563867			match OutboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider, their_network_key,
38573868				their_features, channel_value_satoshis, push_msat, user_channel_id, config,
38583869				self.best_block.read().unwrap().height, outbound_scid_alias, temporary_channel_id, &*self.logger)
@@ -8191,7 +8202,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
81918202		}
81928203
81938204		// 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();
8205+ 		let use_intercept_scid = config.channel_handshake_config.intercept_htlcs_on_channel;
8206+ 		let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_intercept(use_intercept_scid);
81958207		channel.context_mut().set_outbound_scid_alias(outbound_scid_alias);
81968208
81978209		if let Some(message_send_event) = message_send_event {
@@ -8407,7 +8419,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
84078419			},
84088420		};
84098421
8410- 		let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
8422+ 		let use_intercept_scid = self.default_configuration.channel_handshake_config.intercept_htlcs_on_channel;
8423+ 		let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_intercept(use_intercept_scid);
84118424		channel.context_mut().set_outbound_scid_alias(outbound_scid_alias);
84128425
84138426		if let Some(message_send_event) = message_send_event {
@@ -16303,6 +16316,7 @@ mod tests {
1630316316				to_self_delay: Some(200),
1630416317				max_accepted_htlcs: Some(5),
1630516318				channel_reserve_proportional_millionths: Some(20000),
16319+ 				intercept_htlcs_on_channel: None,
1630616320			}),
1630716321			update_overrides: None,
1630816322		};
0 commit comments