rpc: only set balance params when force closing if output not dust
This commit fixes an existing bug that would cause a force closed channel to stay pending forever. In this instance, if one force closes a channel while they have a dust output, and restart before the channel is fully closed, then it wouldn’t have been closed automatically (within the database) by the autopilot agent.
This commit is contained in:
parent
ece1d09a9f
commit
512a5c899b
15
rpcserver.go
15
rpcserver.go
@ -776,6 +776,9 @@ func (r *rpcServer) forceCloseChan(channel *lnwallet.LightningChannel) (*chainha
|
||||
// we'll mark this channel as being in the pending closed state. The
|
||||
// UTXO nursery will mark the channel as fully closed once all the
|
||||
// outputs have been swept.
|
||||
//
|
||||
// TODO(roasbeef): don't set local balance if close summary detects
|
||||
// dust output?
|
||||
chanPoint := channel.ChannelPoint()
|
||||
chanInfo := channel.StateSnapshot()
|
||||
closeInfo := &channeldb.ChannelCloseSummary{
|
||||
@ -783,11 +786,19 @@ func (r *rpcServer) forceCloseChan(channel *lnwallet.LightningChannel) (*chainha
|
||||
ClosingTXID: closeTx.TxHash(),
|
||||
RemotePub: &chanInfo.RemoteIdentity,
|
||||
Capacity: chanInfo.Capacity,
|
||||
SettledBalance: chanInfo.LocalBalance,
|
||||
TimeLockedBalance: chanInfo.LocalBalance,
|
||||
CloseType: channeldb.ForceClose,
|
||||
IsPending: true,
|
||||
}
|
||||
|
||||
// If our commitment output isn't dust or we have active HTLC's on the
|
||||
// commitment transaction, then we'll populate the balances on the
|
||||
// close channel summary.
|
||||
if closeSummary.SelfOutputSignDesc != nil ||
|
||||
len(closeSummary.HtlcResolutions) == 0 {
|
||||
closeInfo.SettledBalance = chanInfo.LocalBalance
|
||||
closeInfo.TimeLockedBalance = chanInfo.LocalBalance
|
||||
}
|
||||
|
||||
if err := channel.DeleteState(closeInfo); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user