@@ -247,20 +247,6 @@ pub struct CommonOpenChannelFields {
247247 pub channel_type : Option < ChannelTypeFeatures > ,
248248}
249249
250- impl CommonOpenChannelFields {
251- /// The [`ChannelParameters`] for this channel.
252- pub fn channel_parameters ( & self ) -> ChannelParameters {
253- ChannelParameters {
254- dust_limit_satoshis : self . dust_limit_satoshis ,
255- max_htlc_value_in_flight_msat : self . max_htlc_value_in_flight_msat ,
256- htlc_minimum_msat : self . htlc_minimum_msat ,
257- commitment_feerate_sat_per_1000_weight : self . commitment_feerate_sat_per_1000_weight ,
258- to_self_delay : self . to_self_delay ,
259- max_accepted_htlcs : self . max_accepted_htlcs ,
260- }
261- }
262- }
263-
264250/// A subset of [`CommonOpenChannelFields`], containing various parameters which are set by the
265251/// channel initiator and which are not part of the channel funding transaction.
266252#[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
@@ -280,6 +266,8 @@ pub struct ChannelParameters {
280266 pub to_self_delay : u16 ,
281267 /// The maximum number of pending HTLCs towards the channel initiator.
282268 pub max_accepted_htlcs : u16 ,
269+ /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
270+ pub channel_reserve_satoshis : Option < u64 > ,
283271}
284272
285273/// An [`open_channel`] message to be sent to or received from a peer.
@@ -297,6 +285,23 @@ pub struct OpenChannel {
297285 pub channel_reserve_satoshis : u64 ,
298286}
299287
288+ impl OpenChannel {
289+ /// The [`ChannelParameters`] for this V1 channel.
290+ pub fn channel_parameters ( & self ) -> ChannelParameters {
291+ ChannelParameters {
292+ dust_limit_satoshis : self . common_fields . dust_limit_satoshis ,
293+ max_htlc_value_in_flight_msat : self . common_fields . max_htlc_value_in_flight_msat ,
294+ htlc_minimum_msat : self . common_fields . htlc_minimum_msat ,
295+ commitment_feerate_sat_per_1000_weight : self
296+ . common_fields
297+ . commitment_feerate_sat_per_1000_weight ,
298+ to_self_delay : self . common_fields . to_self_delay ,
299+ max_accepted_htlcs : self . common_fields . max_accepted_htlcs ,
300+ channel_reserve_satoshis : Some ( self . channel_reserve_satoshis ) ,
301+ }
302+ }
303+ }
304+
300305/// An [`open_channel2`] message to be sent by or received from the channel initiator.
301306///
302307/// Used in V2 channel establishment
@@ -316,6 +321,23 @@ pub struct OpenChannelV2 {
316321 pub require_confirmed_inputs : Option < ( ) > ,
317322}
318323
324+ impl OpenChannelV2 {
325+ /// The [`ChannelParameters`] for this V2 channel.
326+ pub fn channel_parameters ( & self ) -> ChannelParameters {
327+ ChannelParameters {
328+ dust_limit_satoshis : self . common_fields . dust_limit_satoshis ,
329+ max_htlc_value_in_flight_msat : self . common_fields . max_htlc_value_in_flight_msat ,
330+ htlc_minimum_msat : self . common_fields . htlc_minimum_msat ,
331+ commitment_feerate_sat_per_1000_weight : self
332+ . common_fields
333+ . commitment_feerate_sat_per_1000_weight ,
334+ to_self_delay : self . common_fields . to_self_delay ,
335+ max_accepted_htlcs : self . common_fields . max_accepted_htlcs ,
336+ channel_reserve_satoshis : None , // V2 doesn't have this field
337+ }
338+ }
339+ }
340+
319341/// Contains fields that are both common to [`accept_channel`] and [`accept_channel2`] messages.
320342///
321343/// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
0 commit comments