@@ -1177,16 +1177,32 @@ impl Node {
11771177
11781178 /// Close a previously opened channel.
11791179 ///
1180- /// If `force` is set to `true`, we will force-close the channel, potentially broadcasting our
1181- /// latest state. Note that in contrast to cooperative closure, force-closing will have the
1182- /// channel funds time-locked, i.e., they will only be available after the counterparty had
1183- /// time to contest our claim. Force-closing channels also more costly in terms of on-chain
1184- /// fees. So cooperative closure should always be preferred (and tried first).
1180+ /// Will attempt to close a channel coopertively. If this fails, users might need to resort to
1181+ /// [`Node::force_close_channel`].
1182+ pub fn close_channel (
1183+ & self , user_channel_id : & UserChannelId , counterparty_node_id : PublicKey ,
1184+ ) -> Result < ( ) , Error > {
1185+ self . close_channel_internal ( user_channel_id, counterparty_node_id, false )
1186+ }
1187+
1188+ /// Force-close a previously opened channel.
1189+ ///
1190+ /// Will force-close the channel, potentially broadcasting our latest state. Note that in
1191+ /// contrast to cooperative closure, force-closing will have the channel funds time-locked,
1192+ /// i.e., they will only be available after the counterparty had time to contest our claim.
1193+ /// Force-closing channels also more costly in terms of on-chain fees. So cooperative closure
1194+ /// should always be preferred (and tried first).
11851195 ///
11861196 /// Broadcasting the closing transactions will be omitted for Anchor channels if we trust the
11871197 /// counterparty to broadcast for us (see [`AnchorChannelsConfig::trusted_peers_no_reserve`]
11881198 /// for more information).
1189- pub fn close_channel (
1199+ pub fn force_close_channel (
1200+ & self , user_channel_id : & UserChannelId , counterparty_node_id : PublicKey ,
1201+ ) -> Result < ( ) , Error > {
1202+ self . close_channel_internal ( user_channel_id, counterparty_node_id, true )
1203+ }
1204+
1205+ fn close_channel_internal (
11901206 & self , user_channel_id : & UserChannelId , counterparty_node_id : PublicKey , force : bool ,
11911207 ) -> Result < ( ) , Error > {
11921208 let open_channels =
@@ -1235,10 +1251,9 @@ impl Node {
12351251 if open_channels. len ( ) == 1 {
12361252 self . peer_store . remove_peer ( & counterparty_node_id) ?;
12371253 }
1238- Ok ( ( ) )
1239- } else {
1240- Ok ( ( ) )
12411254 }
1255+
1256+ Ok ( ( ) )
12421257 }
12431258
12441259 /// Update the config for a previously opened channel.
0 commit comments