Skip to content

Commit

Permalink
fix: Accept collaborative close offer from coordinator
Browse files Browse the repository at this point in the history
I noticed that both parties can trigger a collaborative dlc channel close, but only the coordinator had the logic implemented to also accept it. This will allow the app also to accept a collab close offer from the coordinator.
  • Loading branch information
holzeis committed Jan 16, 2024
1 parent 14a2169 commit 22e9c49
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions mobile/native/src/ln_dlc/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ impl Node {
/// - Any dlc channel message that has already been processed will be skipped.
///
/// If an offer is received [`ChannelMessage::Offer`], [`ChannelMessage::SettleOffer`],
/// [`ChannelMessage::RenewOffer`] will get automatically accepted. Unless the maturity date of
/// the offer is already outdated.
/// [`ChannelMessage::CollaborativeCloseOffer`], [`ChannelMessage::RenewOffer`] will get
/// automatically accepted. Unless the maturity date of the offer is already outdated.
///
/// FIXME(holzeis): This function manipulates different data objects in different data sources
/// and should use a transaction to make all changes atomic. Not doing so risks of ending up in
Expand Down Expand Up @@ -295,6 +295,18 @@ impl Node {
BackgroundTask::RecoverDlc(TaskStatus::Success),
));
}
ChannelMessage::CollaborativeCloseOffer(close_offer) => {
let channel_id_hex_string = close_offer.channel_id.to_hex();
tracing::info!(
channel_id = channel_id_hex_string,
node_id = node_id.to_string(),
"Received an offer to collaboratively close a channel"
);

// TODO(bonomat): we should verify that the proposed amount is acceptable
self.inner
.accept_dlc_channel_collaborative_close(close_offer.channel_id)?;
}
_ => (),
}

Expand Down

0 comments on commit 22e9c49

Please sign in to comment.