A Lightning Channel does not have any requirement as to when to close the channel, as specified by BOLT. It is entirely decided by the user, and the implementation. For the case of lnd, whenever the user wants to close the channel, he will call
closechannel
trying first to perform a cooperative close, unless specified otherwise:
Name: "closechannel",
Category: "Channels",
Usage: "Close an existing channel.",
Description: `
Close an existing channel. The channel can be closed either cooperatively,
or unilaterally (--force).
A unilateral channel closure means that the latest commitment
transaction will be broadcast to the network. As a result, any settled
funds will be time locked for a few blocks before they can be spent.
In the case of a cooperative closure, One can manually set the fee to
be used for the closing transaction via either the --conf_target or
--sat_per_byte arguments. This will be the starting value used during
fee negotiation. This is optional.
To view which funding_txids/output_indexes can be used for a channel close,
see the channel_point values within the listchannels command output.
The format for a channel_point is 'funding_txid:output_index'.`,
Even when calling closeAllChannels
, being that counterparty node offline, the shell prompts to the user before unilaterally closing the channel:
// If the channel is inactive, we'll attempt to
// unilaterally close the channel, so we should prompt
// the user for confirmation beforehand.
if !channel.GetActive() {
msg := fmt.Sprintf("Unilaterally close channel "+
"with node %s and channel point %s? "+
"The closing transaction will need %d "+
"confirmations before the funds can be "+
"spent. (yes/no): ", channel.RemotePubkey,
channel.ChannelPoint, channel.CsvDelay)