From: benthecarman Date: Thu, 25 Apr 2024 03:36:40 +0000 (-0500) Subject: Add more information to OpenChannelRequest Event X-Git-Tag: v0.0.124-beta~29^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=eb47656a46c8bc5a8cdb205336217cb110c40cfe;p=rust-lightning Add more information to OpenChannelRequest Event --- diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs index 9aa449efb..0cd5cd230 100644 --- a/lightning/src/events/mod.rs +++ b/lightning/src/events/mod.rs @@ -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. diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 28c40856f..b5b89f768 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -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(), diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index e7b43ded1..1558e6d4b 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -237,6 +237,41 @@ pub struct CommonOpenChannelFields { pub channel_type: Option, } +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