]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add more information to OpenChannelRequest Event
authorbenthecarman <benthecarman@live.com>
Thu, 25 Apr 2024 03:36:40 +0000 (22:36 -0500)
committerbenthecarman <benthecarman@live.com>
Mon, 29 Jul 2024 18:56:58 +0000 (13:56 -0500)
lightning/src/events/mod.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/msgs.rs

index 9aa449efbaa9a32fd7811888fadd386dca4d39ee..0cd5cd2304245b35700eed9fa751e450a8d96e1b 100644 (file)
@@ -1308,6 +1308,10 @@ pub enum Event {
                ///
                /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
                channel_type: ChannelTypeFeatures,
+               /// True if this channel is (or will be) publicly-announced.
+               is_public: bool,
+               /// Channel parameters given by the counterparty.
+               params: msgs::ChannelParameters,
        },
        /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
        /// forward it.
index 28c40856f50cfa52ca299534d5695c8a69155116..b5b89f7686db250c753d24fa96f89cad0318e230 100644 (file)
@@ -7395,12 +7395,15 @@ where
                                        MsgHandleErrInternal::from_chan_no_close(e, msg.common_fields.temporary_channel_id)
                                )?;
                        let mut pending_events = self.pending_events.lock().unwrap();
+                       let is_public = (msg.common_fields.channel_flags & 1) == 1;
                        pending_events.push_back((events::Event::OpenChannelRequest {
                                temporary_channel_id: msg.common_fields.temporary_channel_id.clone(),
                                counterparty_node_id: counterparty_node_id.clone(),
                                funding_satoshis: msg.common_fields.funding_satoshis,
                                push_msat: msg.push_msat,
                                channel_type,
+                               is_public,
+                               params: msg.common_fields.channel_parameters(),
                        }, None));
                        peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest {
                                open_channel_msg: msg.clone(),
index e7b43ded11d3ee5bb19b6014cfbc9aa5a1deaf6d..1558e6d4b0aff14a8fe3c8ada215d96be81fb206 100644 (file)
@@ -237,6 +237,41 @@ pub struct CommonOpenChannelFields {
        pub channel_type: Option<ChannelTypeFeatures>,
 }
 
+impl CommonOpenChannelFields {
+       /// The [`ChannelParameters`] for this channel.
+       pub fn channel_parameters(&self) -> ChannelParameters {
+               ChannelParameters {
+                       dust_limit_satoshis: self.dust_limit_satoshis,
+                       max_htlc_value_in_flight_msat: self.max_htlc_value_in_flight_msat,
+                       htlc_minimum_msat: self.htlc_minimum_msat,
+                       commitment_feerate_sat_per_1000_weight: self.commitment_feerate_sat_per_1000_weight,
+                       to_self_delay: self.to_self_delay,
+                       max_accepted_htlcs: self.max_accepted_htlcs,
+               }
+       }
+}
+
+/// A subset of [`CommonOpenChannelFields`], containing various parameters which are set by the
+/// counterparty and which are not part of the channel funding transaction.
+#[derive(Clone, Debug, Hash, PartialEq, Eq)]
+pub struct ChannelParameters {
+       /// The threshold below which outputs on transactions broadcast by the channel initiator will be
+       /// omitted
+       pub dust_limit_satoshis: u64,
+       /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
+       pub max_htlc_value_in_flight_msat: u64,
+       /// The minimum HTLC size incoming to channel initiator, in milli-satoshi
+       pub htlc_minimum_msat: u64,
+       /// The feerate for the commitment transaction set by the channel initiator until updated by
+       /// [`UpdateFee`]
+       pub commitment_feerate_sat_per_1000_weight: u32,
+       /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
+       /// broadcast a commitment transaction
+       pub to_self_delay: u16,
+       /// The maximum number of inbound HTLCs towards channel initiator
+       pub max_accepted_htlcs: u16,
+}
+
 /// An [`open_channel`] message to be sent to or received from a peer.
 ///
 /// Used in V1 channel establishment