Skip to content

Add more information to OpenChannelRequest Event #3019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
35 changes: 35 additions & 0 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat confusing in context - for an inbound channel this is the amount of blocks that we'll have to wait.

/// 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
Expand Down
Loading