-
Notifications
You must be signed in to change notification settings - Fork 130
Expose ChannelDetails::channel_shutdown_state
#827
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
Open
f3r10
wants to merge
1
commit into
lightningdevkit:main
Choose a base branch
from
f3r10:feat/expose_channel_shutdown_state
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+52
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,9 @@ use bitcoin::{OutPoint, ScriptBuf}; | |
| use bitcoin_payment_instructions::onion_message_resolver::LDKOnionMessageDNSSECHrnResolver; | ||
| use lightning::chain::chainmonitor; | ||
| use lightning::impl_writeable_tlv_based; | ||
| use lightning::ln::channel_state::ChannelDetails as LdkChannelDetails; | ||
| use lightning::ln::channel_state::{ | ||
| ChannelDetails as LdkChannelDetails, ChannelShutdownState as LdkChannelShutdownState, | ||
| }; | ||
| use lightning::ln::msgs::{RoutingMessageHandler, SocketAddress}; | ||
| use lightning::ln::peer_handler::IgnoringMessageHandler; | ||
| use lightning::ln::types::ChannelId; | ||
|
|
@@ -347,6 +349,40 @@ impl fmt::Display for UserChannelId { | |
| } | ||
| } | ||
|
|
||
| /// The shutdown state of a channel as returned in [`ChannelDetails::channel_shutdown_state`]. | ||
| /// | ||
| /// [`ChannelDetails::channel_shutdown_state`]: crate::ChannelDetails::channel_shutdown_state | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] | ||
| pub enum ChannelShutdownState { | ||
| /// Channel has not sent or received a shutdown message. | ||
| NotShuttingDown, | ||
| /// Local node has sent a shutdown message for this channel. | ||
| ShutdownInitiated, | ||
| /// Shutdown message exchanges have concluded and the channels are in the midst of | ||
| /// resolving all existing open HTLCs before closing can continue. | ||
| ResolvingHTLCs, | ||
| /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates. | ||
| NegotiatingClosingFee, | ||
| /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about | ||
| /// to drop the channel. | ||
| ShutdownComplete, | ||
| } | ||
|
|
||
| impl From<LdkChannelShutdownState> for ChannelShutdownState { | ||
| fn from(value: LdkChannelShutdownState) -> Self { | ||
| match value { | ||
| LdkChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, | ||
| LdkChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, | ||
| LdkChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, | ||
| LdkChannelShutdownState::NegotiatingClosingFee => { | ||
| ChannelShutdownState::NegotiatingClosingFee | ||
| }, | ||
| LdkChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Details of a channel as returned by [`Node::list_channels`]. | ||
| /// | ||
| /// When a channel is spliced, most fields continue to refer to the original pre-splice channel | ||
|
|
@@ -529,6 +565,10 @@ pub struct ChannelDetails { | |
| pub inbound_htlc_maximum_msat: Option<u64>, | ||
| /// Set of configurable parameters that affect channel operation. | ||
| pub config: ChannelConfig, | ||
| /// The current shutdown state of the channel, if any. | ||
| /// | ||
| /// Returns `None` for channels that have not yet started the shutdown process. | ||
|
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. Could we replace this to accurately reflect what the source from the library says |
||
| pub channel_shutdown_state: Option<ChannelShutdownState>, | ||
| } | ||
|
|
||
| impl From<LdkChannelDetails> for ChannelDetails { | ||
|
|
@@ -584,6 +624,7 @@ impl From<LdkChannelDetails> for ChannelDetails { | |
| inbound_htlc_maximum_msat: value.inbound_htlc_maximum_msat, | ||
| // unwrap safety: `config` is only `None` for LDK objects serialized prior to 0.0.109. | ||
| config: value.config.map(|c| c.into()).unwrap(), | ||
| channel_shutdown_state: value.channel_shutdown_state.map(|s| s.into()), | ||
| } | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we really need to duplicate this enum here, or could we get away with using the upstream one and only using
#[uniffi::remote(Enum)]foruniffi?