From bb7ef6c2901a9582e19511ab0a974d1de3ef1205 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 15 Oct 2021 20:16:15 +0000 Subject: [PATCH] Rename create_channel param to user_channel_id to standardize it --- fuzz/src/router.rs | 2 +- lightning/src/ln/channelmanager.rs | 23 ++++++++++++----------- lightning/src/routing/router.rs | 2 +- lightning/src/util/events.rs | 8 ++++---- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs index 6c792916..b80a8284 100644 --- a/fuzz/src/router.rs +++ b/fuzz/src/router.rs @@ -216,7 +216,7 @@ pub fn do_test(data: &[u8], out: Out) { funding_txo: Some(OutPoint { txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0 }), short_channel_id: Some(scid), channel_value_satoshis: slice_to_be64(get_slice!(8)), - user_id: 0, inbound_capacity_msat: 0, + user_channel_id: 0, inbound_capacity_msat: 0, unspendable_punishment_reserve: None, confirmations_required: None, force_close_spend_delay: None, diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 9be26a1e..0106fe51 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -776,8 +776,8 @@ pub struct ChannelDetails { /// /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat pub unspendable_punishment_reserve: Option, - /// The user_id passed in to create_channel, or 0 if the channel was inbound. - pub user_id: u64, + /// The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound. + pub user_channel_id: u64, /// The available outbound capacity for sending HTLCs to the remote peer. This does not include /// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not /// available for inclusion in new outbound HTLCs). This further does not include any pending @@ -1272,11 +1272,12 @@ impl ChannelMana /// Creates a new outbound channel to the given remote node and with the given value. /// - /// `user_id` will be provided back as `user_channel_id` in [`Event::FundingGenerationReady`] - /// to allow tracking of which events correspond with which `create_channel` call. Note that - /// the `user_channel_id` defaults to 0 for inbound channels, so you may wish to avoid using 0 - /// for `user_id` here. `user_id` has no meaning inside of LDK, it is simply copied to events - /// and otherwise ignored. + /// `user_channel_id` will be provided back as in + /// [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events + /// correspond with which `create_channel` call. Note that the `user_channel_id` defaults to 0 + /// for inbound channels, so you may wish to avoid using 0 for `user_channel_id` here. + /// `user_channel_id` has no meaning inside of LDK, it is simply copied to events and otherwise + /// ignored. /// /// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is /// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. @@ -1292,10 +1293,10 @@ impl ChannelMana /// one derived from the funding transaction's TXID. If the counterparty rejects the channel /// immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`]. /// - /// [`Event::FundingGenerationReady`]: events::Event::FundingGenerationReady + /// [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id /// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id /// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id - pub fn create_channel(&self, their_network_key: PublicKey, channel_value_satoshis: u64, push_msat: u64, user_id: u64, override_config: Option) -> Result<[u8; 32], APIError> { + pub fn create_channel(&self, their_network_key: PublicKey, channel_value_satoshis: u64, push_msat: u64, user_channel_id: u64, override_config: Option) -> Result<[u8; 32], APIError> { if channel_value_satoshis < 1000 { return Err(APIError::APIMisuseError { err: format!("Channel value must be at least 1000 satoshis. It was {}", channel_value_satoshis) }); } @@ -1307,7 +1308,7 @@ impl ChannelMana let peer_state = peer_state.lock().unwrap(); let their_features = &peer_state.latest_features; let config = if override_config.is_some() { override_config.as_ref().unwrap() } else { &self.default_configuration }; - Channel::new_outbound(&self.fee_estimator, &self.keys_manager, their_network_key, their_features, channel_value_satoshis, push_msat, user_id, config)? + Channel::new_outbound(&self.fee_estimator, &self.keys_manager, their_network_key, their_features, channel_value_satoshis, push_msat, user_channel_id, config)? }, None => return Err(APIError::ChannelUnavailable { err: format!("Not connected to node: {}", their_network_key) }), } @@ -1360,7 +1361,7 @@ impl ChannelMana unspendable_punishment_reserve: to_self_reserve_satoshis, inbound_capacity_msat, outbound_capacity_msat, - user_id: channel.get_user_id(), + user_channel_id: channel.get_user_id(), confirmations_required: channel.minimum_depth(), force_close_spend_delay: channel.get_counterparty_selected_contest_delay(), is_outbound: channel.is_outbound(), diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index d6adb889..9e02e10f 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1327,7 +1327,7 @@ mod tests { funding_txo: Some(OutPoint { txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0 }), short_channel_id, channel_value_satoshis: 0, - user_id: 0, + user_channel_id: 0, outbound_capacity_msat, inbound_capacity_msat: 42, unspendable_punishment_reserve: None, diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs index 8502f9be..7ea369f5 100644 --- a/lightning/src/util/events.rs +++ b/lightning/src/util/events.rs @@ -146,8 +146,8 @@ pub enum Event { channel_value_satoshis: u64, /// The script which should be used in the transaction output. output_script: Script, - /// The `user_id` value passed in to [`ChannelManager::create_channel`], or 0 for an - /// inbound channel. + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for + /// an inbound channel. /// /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel user_channel_id: u64, @@ -265,8 +265,8 @@ pub enum Event { /// The channel_id of the channel which has been closed. Note that on-chain transactions /// resolving the channel are likely still awaiting confirmation. channel_id: [u8; 32], - /// The `user_id` value passed in to [`ChannelManager::create_channel`], or 0 for an - /// inbound channel. This will always be zero for objects serialized with LDK versions + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for + /// an inbound channel. This will always be zero for objects serialized with LDK versions /// prior to 0.0.102. /// /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel -- 2.30.2