@@ -3771,19 +3771,21 @@ where
3771
3771
3772
3772
#[cfg(test)]
3773
3773
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(
3775
+ fake_scid::Namespace::OutboundAlias
3776
+ )
3775
3777
}
3776
3778
3777
3779
#[rustfmt::skip]
3778
- fn create_and_insert_outbound_scid_alias (&self) -> u64 {
3780
+ fn create_and_insert_outbound_scid_alias_with_namespace (&self, namespace: fake_scid::Namespace ) -> u64 {
3779
3781
let height = self.best_block.read().unwrap().height;
3780
3782
let mut outbound_scid_alias = 0;
3781
3783
let mut i = 0;
3782
3784
loop {
3783
3785
if cfg!(fuzzing) { // fuzzing chacha20 doesn't use the key at all so we always get the same alias
3784
3786
outbound_scid_alias += 1;
3785
3787
} else {
3786
- outbound_scid_alias = fake_scid::Namespace::OutboundAlias .get_fake_scid(height, &self.chain_hash, &self.fake_scid_rand_bytes, &self.entropy_source);
3788
+ outbound_scid_alias = namespace .get_fake_scid(height, &self.chain_hash, &self.fake_scid_rand_bytes, &self.entropy_source);
3787
3789
}
3788
3790
if outbound_scid_alias != 0 && self.outbound_scid_aliases.lock().unwrap().insert(outbound_scid_alias) {
3789
3791
break;
@@ -3794,6 +3796,15 @@ where
3794
3796
outbound_scid_alias
3795
3797
}
3796
3798
3799
+ /// Determines the appropriate outbound SCID namespace based on the intercept_htlcs_on_channel configuration.
3800
+ fn get_outbound_scid_namespace(intercept_htlcs_on_channel: bool) -> fake_scid::Namespace {
3801
+ if intercept_htlcs_on_channel {
3802
+ fake_scid::Namespace::Intercept
3803
+ } else {
3804
+ fake_scid::Namespace::OutboundAlias
3805
+ }
3806
+ }
3807
+
3797
3808
/// Creates a new outbound channel to the given remote node and with the given value.
3798
3809
///
3799
3810
/// `user_channel_id` will be provided back as in
@@ -3850,9 +3861,10 @@ where
3850
3861
}
3851
3862
3852
3863
let mut channel = {
3853
- let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
3854
- let their_features = &peer_state.latest_features;
3855
3864
let config = if override_config.is_some() { override_config.as_ref().unwrap() } else { &self.default_configuration };
3865
+ let outbound_scid_namespace = Self::get_outbound_scid_namespace(config.channel_handshake_config.intercept_htlcs_on_channel);
3866
+ let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_namespace(outbound_scid_namespace);
3867
+ let their_features = &peer_state.latest_features;
3856
3868
match OutboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider, their_network_key,
3857
3869
their_features, channel_value_satoshis, push_msat, user_channel_id, config,
3858
3870
self.best_block.read().unwrap().height, outbound_scid_alias, temporary_channel_id, &*self.logger)
@@ -8191,7 +8203,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8191
8203
}
8192
8204
8193
8205
// 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();
8206
+ let outbound_scid_namespace = Self::get_outbound_scid_namespace(config.channel_handshake_config.intercept_htlcs_on_channel);
8207
+ let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_namespace(outbound_scid_namespace);
8195
8208
channel.context_mut().set_outbound_scid_alias(outbound_scid_alias);
8196
8209
8197
8210
if let Some(message_send_event) = message_send_event {
@@ -8407,7 +8420,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8407
8420
},
8408
8421
};
8409
8422
8410
- let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
8423
+ let outbound_scid_namespace = Self::get_outbound_scid_namespace(self.default_configuration.channel_handshake_config.intercept_htlcs_on_channel);
8424
+ let outbound_scid_alias = self.create_and_insert_outbound_scid_alias_with_namespace(outbound_scid_namespace);
8411
8425
channel.context_mut().set_outbound_scid_alias(outbound_scid_alias);
8412
8426
8413
8427
if let Some(message_send_event) = message_send_event {
@@ -16303,6 +16317,7 @@ mod tests {
16303
16317
to_self_delay: Some(200),
16304
16318
max_accepted_htlcs: Some(5),
16305
16319
channel_reserve_proportional_millionths: Some(20000),
16320
+ intercept_htlcs_on_channel: None,
16306
16321
}),
16307
16322
update_overrides: None,
16308
16323
};
0 commit comments