-
Notifications
You must be signed in to change notification settings - Fork 433
Expose channel_reserve_satoshis via ChannelParameters
#4319
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1682,6 +1682,25 @@ pub(super) enum OpenChannelMessageRef<'a> { | |
| V2(&'a msgs::OpenChannelV2), | ||
| } | ||
|
|
||
| impl<'a> OpenChannelMessageRef<'a> { | ||
| pub(super) fn channel_parameters(&self) -> msgs::ChannelParameters { | ||
| let (common_fields, channel_reserve_satoshis) = match self { | ||
| Self::V1(msg) => (&msg.common_fields, Some(msg.channel_reserve_satoshis)), | ||
| Self::V2(msg) => (&msg.common_fields, None), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test suite still passes if I set this to |
||
| }; | ||
| msgs::ChannelParameters { | ||
| dust_limit_satoshis: common_fields.dust_limit_satoshis, | ||
| max_htlc_value_in_flight_msat: common_fields.max_htlc_value_in_flight_msat, | ||
| htlc_minimum_msat: common_fields.htlc_minimum_msat, | ||
| commitment_feerate_sat_per_1000_weight: common_fields | ||
| .commitment_feerate_sat_per_1000_weight, | ||
| to_self_delay: common_fields.to_self_delay, | ||
| max_accepted_htlcs: common_fields.max_accepted_htlcs, | ||
| channel_reserve_satoshis, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// A not-yet-accepted inbound (from counterparty) channel. Once | ||
| /// accepted, the parameters will be used to construct a channel. | ||
| pub(super) struct InboundChannelRequest { | ||
|
|
@@ -10716,7 +10735,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/ | |
| }, | ||
| channel_type, | ||
| is_announced, | ||
| params: common_fields.channel_parameters(), | ||
| params: msg.channel_parameters(), | ||
| }, None)); | ||
| peer_state.inbound_channel_request_by_id.insert(channel_id, InboundChannelRequest { | ||
| open_channel_msg: match msg { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,20 +244,6 @@ 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 | ||
| /// channel initiator and which are not part of the channel funding transaction. | ||
| #[derive(Clone, Debug, Hash, PartialEq, Eq)] | ||
|
|
@@ -277,6 +263,19 @@ pub struct ChannelParameters { | |
| pub to_self_delay: u16, | ||
| /// The maximum number of pending HTLCs towards the channel initiator. | ||
| pub max_accepted_htlcs: u16, | ||
| /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel. | ||
| /// | ||
| /// For V1 channels (`open_channel`), this is the explicit `channel_reserve_satoshis` value | ||
| /// from the counterparty. | ||
|
Comment on lines
+266
to
+269
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As described above, this is a subset of |
||
| /// | ||
| /// For V2 channels (`open_channel2`), this is `None` at the time of [`Event::OpenChannelRequest`] | ||
| /// because the channel reserve is calculated as `max(1% of total_channel_value, dust_limit_satoshis)` | ||
| /// per the spec, where `total_channel_value` includes both the initiator's and acceptor's funding | ||
| /// contributions. Since the acceptor's contribution is not yet known when the event is generated, | ||
| /// the final reserve value cannot be determined at that point. | ||
| /// | ||
| /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest | ||
| pub channel_reserve_satoshis: Option<u64>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A question for @tnull : We also note for Seems to me now we can also differentiate V1 vs V2 based on the To keep things consistent, would it be worth moving |
||
| } | ||
|
|
||
| /// An [`open_channel`] message to be sent to or received from a peer. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described elsewhere, let's also add coverage for the V2 case