Skip to content

Commit c7419b4

Browse files
authored
Merge pull request lightningdevkit#3019 from benthecarman/is-public
Add more information to OpenChannelRequest Event
2 parents 85e5e6a + eb47656 commit c7419b4

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

Diff for: lightning/src/events/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,10 @@ pub enum Event {
13081308
///
13091309
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
13101310
channel_type: ChannelTypeFeatures,
1311+
/// True if this channel is (or will be) publicly-announced.
1312+
is_public: bool,
1313+
/// Channel parameters given by the counterparty.
1314+
params: msgs::ChannelParameters,
13111315
},
13121316
/// Indicates that the HTLC was accepted, but could not be processed when or after attempting to
13131317
/// forward it.

Diff for: lightning/src/ln/channelmanager.rs

+3
Original file line numberDiff line numberDiff line change
@@ -7392,12 +7392,15 @@ where
73927392
MsgHandleErrInternal::from_chan_no_close(e, msg.common_fields.temporary_channel_id)
73937393
)?;
73947394
let mut pending_events = self.pending_events.lock().unwrap();
7395+
let is_public = (msg.common_fields.channel_flags & 1) == 1;
73957396
pending_events.push_back((events::Event::OpenChannelRequest {
73967397
temporary_channel_id: msg.common_fields.temporary_channel_id.clone(),
73977398
counterparty_node_id: counterparty_node_id.clone(),
73987399
funding_satoshis: msg.common_fields.funding_satoshis,
73997400
push_msat: msg.push_msat,
74007401
channel_type,
7402+
is_public,
7403+
params: msg.common_fields.channel_parameters(),
74017404
}, None));
74027405
peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest {
74037406
open_channel_msg: msg.clone(),

Diff for: lightning/src/ln/msgs.rs

+35
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,41 @@ pub struct CommonOpenChannelFields {
237237
pub channel_type: Option<ChannelTypeFeatures>,
238238
}
239239

240+
impl CommonOpenChannelFields {
241+
/// The [`ChannelParameters`] for this channel.
242+
pub fn channel_parameters(&self) -> ChannelParameters {
243+
ChannelParameters {
244+
dust_limit_satoshis: self.dust_limit_satoshis,
245+
max_htlc_value_in_flight_msat: self.max_htlc_value_in_flight_msat,
246+
htlc_minimum_msat: self.htlc_minimum_msat,
247+
commitment_feerate_sat_per_1000_weight: self.commitment_feerate_sat_per_1000_weight,
248+
to_self_delay: self.to_self_delay,
249+
max_accepted_htlcs: self.max_accepted_htlcs,
250+
}
251+
}
252+
}
253+
254+
/// A subset of [`CommonOpenChannelFields`], containing various parameters which are set by the
255+
/// counterparty and which are not part of the channel funding transaction.
256+
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
257+
pub struct ChannelParameters {
258+
/// The threshold below which outputs on transactions broadcast by the channel initiator will be
259+
/// omitted
260+
pub dust_limit_satoshis: u64,
261+
/// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
262+
pub max_htlc_value_in_flight_msat: u64,
263+
/// The minimum HTLC size incoming to channel initiator, in milli-satoshi
264+
pub htlc_minimum_msat: u64,
265+
/// The feerate for the commitment transaction set by the channel initiator until updated by
266+
/// [`UpdateFee`]
267+
pub commitment_feerate_sat_per_1000_weight: u32,
268+
/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they
269+
/// broadcast a commitment transaction
270+
pub to_self_delay: u16,
271+
/// The maximum number of inbound HTLCs towards channel initiator
272+
pub max_accepted_htlcs: u16,
273+
}
274+
240275
/// An [`open_channel`] message to be sent to or received from a peer.
241276
///
242277
/// Used in V1 channel establishment

0 commit comments

Comments
 (0)