-
Notifications
You must be signed in to change notification settings - Fork 414
Somewhat clean up closure pipelines #3881
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
TheBlueMatt
wants to merge
10
commits into
lightningdevkit:main
Choose a base branch
from
TheBlueMatt:2025-06-fc-always-broadcast
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.
+716
−657
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
81d7b49
Remove unnecessary return value from force_close_channel_with_peer
TheBlueMatt 57e9820
Add a `ClosureReason::LocallyCoopClosedUnfundedChannel`
TheBlueMatt cda3339
Use `ClosureReason::ProcessingError` not `HolderForceClosed` on err
TheBlueMatt 05c3402
Misc `ClosureReason` generation cleanups
TheBlueMatt 1d4c966
Add a `message` field to `ClosureReason::HolderForceClosed`
TheBlueMatt c66c56b
Clean up `MsgHandleErrInternal` method annotations and format
TheBlueMatt f919763
Drop the (broken) ability to disable broadcast when FC'ing a chan
TheBlueMatt 9cbdbb8
Rely on `convert_channel_err` over `locked_close_chan`
TheBlueMatt 1f46eab
Avoid passing `FundingScope` around during channel closure
TheBlueMatt 12c0a08
Decide on close-broadcasting commitment txn based on channel state
TheBlueMatt 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
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 |
---|---|---|
|
@@ -325,16 +325,15 @@ pub enum ClosureReason { | |
/// Whether or not the latest transaction was broadcasted when the channel was force | ||
/// closed. | ||
/// | ||
/// Channels closed using [`ChannelManager::force_close_broadcasting_latest_txn`] will have | ||
/// this field set to true, whereas channels closed using [`ChannelManager::force_close_without_broadcasting_txn`] | ||
/// or force-closed prior to being funded will have this field set to false. | ||
/// This will be set to `Some(true)` for any channels closed after their funding | ||
/// transaction was (or might have been) broadcasted, and `Some(false)` for any channels | ||
/// closed prior to their funding transaction being broadcasted. | ||
/// | ||
/// This will be `None` for objects generated or written by LDK 0.0.123 and | ||
/// earlier. | ||
/// | ||
/// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn. | ||
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn. | ||
broadcasted_latest_txn: Option<bool>, | ||
/// XXX: What was passed to force_close! | ||
message: String, | ||
}, | ||
/// The channel was closed after negotiating a cooperative close and we've now broadcasted | ||
/// the cooperative close transaction. Note the shutdown may have been initiated by us. | ||
|
@@ -356,7 +355,8 @@ pub enum ClosureReason { | |
/// commitment transaction came from our counterparty, but it may also have come from | ||
/// a copy of our own `ChannelMonitor`. | ||
CommitmentTxConfirmed, | ||
/// The funding transaction failed to confirm in a timely manner on an inbound channel. | ||
/// The funding transaction failed to confirm in a timely manner on an inbound channel or the | ||
/// counterparty failed to fund the channel in a timely manner. | ||
FundingTimedOut, | ||
/// Closure generated from processing an event, likely a HTLC forward/relay/reception. | ||
ProcessingError { | ||
|
@@ -383,6 +383,12 @@ pub enum ClosureReason { | |
/// The counterparty requested a cooperative close of a channel that had not been funded yet. | ||
/// The channel has been immediately closed. | ||
CounterpartyCoopClosedUnfundedChannel, | ||
/// We requested a cooperative close of a channel that had not been funded yet. | ||
/// The channel has been immediately closed. | ||
/// | ||
/// Note that events containing this variant will be lost on downgrade to a version of LDK | ||
/// prior to 0.2. | ||
LocallyCoopClosedUnfundedChannel, | ||
/// Another channel in the same funding batch closed before the funding transaction | ||
/// was ready to be broadcast. | ||
FundingBatchClosure, | ||
|
@@ -412,12 +418,13 @@ impl core::fmt::Display for ClosureReason { | |
ClosureReason::CounterpartyForceClosed { peer_msg } => { | ||
f.write_fmt(format_args!("counterparty force-closed with message: {}", peer_msg)) | ||
}, | ||
ClosureReason::HolderForceClosed { broadcasted_latest_txn } => { | ||
f.write_str("user force-closed the channel")?; | ||
ClosureReason::HolderForceClosed { broadcasted_latest_txn, message } => { | ||
f.write_str("user force-closed the channel with the message \"")?; | ||
f.write_str(message)?; | ||
if let Some(brodcasted) = broadcasted_latest_txn { | ||
write!( | ||
f, | ||
" and {} the latest transaction", | ||
"\" and {} the latest transaction", | ||
if *brodcasted { "broadcasted" } else { "elected not to broadcast" } | ||
) | ||
} else { | ||
|
@@ -454,6 +461,9 @@ impl core::fmt::Display for ClosureReason { | |
ClosureReason::CounterpartyCoopClosedUnfundedChannel => { | ||
f.write_str("the peer requested the unfunded channel be closed") | ||
}, | ||
ClosureReason::LocallyCoopClosedUnfundedChannel => { | ||
f.write_str("we requested the unfunded channel be closed") | ||
}, | ||
ClosureReason::FundingBatchClosure => { | ||
f.write_str("another channel in the same funding batch closed") | ||
}, | ||
|
@@ -472,7 +482,10 @@ impl core::fmt::Display for ClosureReason { | |
impl_writeable_tlv_based_enum_upgradable!(ClosureReason, | ||
(0, CounterpartyForceClosed) => { (1, peer_msg, required) }, | ||
(1, FundingTimedOut) => {}, | ||
(2, HolderForceClosed) => { (1, broadcasted_latest_txn, option) }, | ||
(2, HolderForceClosed) => { | ||
(1, broadcasted_latest_txn, option), | ||
(3, message, required), // XXX: upgrade to empty string or whatever and document | ||
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. Same here: unaddressed |
||
}, | ||
(6, CommitmentTxConfirmed) => {}, | ||
(4, LegacyCooperativeClosure) => {}, | ||
(8, ProcessingError) => { (1, err, required) }, | ||
|
@@ -487,6 +500,7 @@ impl_writeable_tlv_based_enum_upgradable!(ClosureReason, | |
(0, peer_feerate_sat_per_kw, required), | ||
(2, required_feerate_sat_per_kw, required), | ||
}, | ||
(25, LocallyCoopClosedUnfundedChannel) => {}, | ||
); | ||
|
||
/// The type of HTLC handling performed in [`Event::HTLCHandlingFailed`]. | ||
|
@@ -1459,7 +1473,7 @@ pub enum Event { | |
/// | ||
/// To accept the request (and in the case of a dual-funded channel, not contribute funds), | ||
/// call [`ChannelManager::accept_inbound_channel`]. | ||
/// To reject the request, call [`ChannelManager::force_close_without_broadcasting_txn`]. | ||
/// To reject the request, call [`ChannelManager::force_close_broadcasting_latest_txn`]. | ||
/// Note that a ['ChannelClosed`] event will _not_ be triggered if the channel is rejected. | ||
/// | ||
/// The event is only triggered when a new open channel request is received and the | ||
|
@@ -1470,27 +1484,27 @@ pub enum Event { | |
/// returning `Err(ReplayEvent ())`) and won't be persisted across restarts. | ||
/// | ||
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel | ||
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn | ||
/// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn | ||
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels | ||
OpenChannelRequest { | ||
/// The temporary channel ID of the channel requested to be opened. | ||
/// | ||
/// When responding to the request, the `temporary_channel_id` should be passed | ||
/// back to the ChannelManager through [`ChannelManager::accept_inbound_channel`] to accept, | ||
/// or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject. | ||
/// or through [`ChannelManager::force_close_broadcasting_latest_txn`] to reject. | ||
/// | ||
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel | ||
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn | ||
/// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn | ||
temporary_channel_id: ChannelId, | ||
/// The node_id of the counterparty requesting to open the channel. | ||
/// | ||
/// When responding to the request, the `counterparty_node_id` should be passed | ||
/// back to the `ChannelManager` through [`ChannelManager::accept_inbound_channel`] to | ||
/// accept the request, or through [`ChannelManager::force_close_without_broadcasting_txn`] to reject the | ||
/// request. | ||
/// accept the request, or through [`ChannelManager::force_close_broadcasting_latest_txn`] | ||
/// to reject the request. | ||
/// | ||
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel | ||
/// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn | ||
/// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn | ||
counterparty_node_id: PublicKey, | ||
/// The channel value of the requested channel. | ||
funding_satoshis: u64, | ||
|
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
Oops, something went wrong.
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.
Seems this
XXX
still needs to be addressed.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.
Ha, sorry, I was somewhat rushing to get it up last night. Just needed to write docs here.