Skip to content
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

fix: Do not create dlc protocol entry for force closed channels #2588

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions coordinator/src/node/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,19 @@ pub struct DlcChannel {
}

impl Node {
pub async fn close_dlc_channel(
&self,
channel_id: DlcChannelId,
is_force_close: bool,
) -> Result<()> {
pub async fn force_close_dlc_channel(&self, channel_id: DlcChannelId) -> Result<()> {
self.inner.close_dlc_channel(channel_id, true).await?;
Ok(())
}

pub async fn close_dlc_channel(&self, channel_id: DlcChannelId) -> Result<()> {
let channel = self.inner.get_dlc_channel_by_id(&channel_id)?;
let previous_id = channel
.get_reference_id()
.map(ProtocolId::try_from)
.transpose()?;

let protocol_id = self
.inner
.close_dlc_channel(channel_id, is_force_close)
.await?;
let protocol_id = self.inner.close_dlc_channel(channel_id, false).await?;

let protocol_executor = dlc_protocol::DlcProtocolExecutor::new(self.pool.clone());
protocol_executor.start_dlc_protocol(
Expand Down
10 changes: 5 additions & 5 deletions coordinator/src/routes/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ pub async fn close_channel(

tracing::info!(channel_id = %channel_id_string, "Attempting to close channel");

state
.node
.close_dlc_channel(channel_id, params.force.unwrap_or_default())
.await
.map_err(|e| AppError::InternalServerError(format!("{e:#}")))?;
match params.force.unwrap_or_default() {
true => state.node.force_close_dlc_channel(channel_id).await,
false => state.node.close_dlc_channel(channel_id).await,
}
.map_err(|e| AppError::InternalServerError(format!("{e:#}")))?;

Ok(())
}
Expand Down
Loading