Skip to content

Commit df7be13

Browse files
authored
Merge pull request #2588 from get10101/fix/do-not-create-dlc-protocol-for-force-closed-channels
fix: Do not create dlc protocol entry for force closed channels
2 parents a544aa7 + 357a9f5 commit df7be13

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

coordinator/src/node/channel.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,19 @@ pub struct DlcChannel {
6161
}
6262

6363
impl Node {
64-
pub async fn close_dlc_channel(
65-
&self,
66-
channel_id: DlcChannelId,
67-
is_force_close: bool,
68-
) -> Result<()> {
64+
pub async fn force_close_dlc_channel(&self, channel_id: DlcChannelId) -> Result<()> {
65+
self.inner.close_dlc_channel(channel_id, true).await?;
66+
Ok(())
67+
}
68+
69+
pub async fn close_dlc_channel(&self, channel_id: DlcChannelId) -> Result<()> {
6970
let channel = self.inner.get_dlc_channel_by_id(&channel_id)?;
7071
let previous_id = channel
7172
.get_reference_id()
7273
.map(ProtocolId::try_from)
7374
.transpose()?;
7475

75-
let protocol_id = self
76-
.inner
77-
.close_dlc_channel(channel_id, is_force_close)
78-
.await?;
76+
let protocol_id = self.inner.close_dlc_channel(channel_id, false).await?;
7977

8078
let protocol_executor = dlc_protocol::DlcProtocolExecutor::new(self.pool.clone());
8179
protocol_executor.start_dlc_protocol(

coordinator/src/routes/admin.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ pub async fn close_channel(
296296

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

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

305305
Ok(())
306306
}

0 commit comments

Comments
 (0)