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
27
rpcserver.go
27
rpcserver.go
@ -776,18 +776,29 @@ func (r *rpcServer) forceCloseChan(channel *lnwallet.LightningChannel) (*chainha
|
|||||||
// we'll mark this channel as being in the pending closed state. The
|
// 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
|
// UTXO nursery will mark the channel as fully closed once all the
|
||||||
// outputs have been swept.
|
// outputs have been swept.
|
||||||
|
//
|
||||||
|
// TODO(roasbeef): don't set local balance if close summary detects
|
||||||
|
// dust output?
|
||||||
chanPoint := channel.ChannelPoint()
|
chanPoint := channel.ChannelPoint()
|
||||||
chanInfo := channel.StateSnapshot()
|
chanInfo := channel.StateSnapshot()
|
||||||
closeInfo := &channeldb.ChannelCloseSummary{
|
closeInfo := &channeldb.ChannelCloseSummary{
|
||||||
ChanPoint: *chanPoint,
|
ChanPoint: *chanPoint,
|
||||||
ClosingTXID: closeTx.TxHash(),
|
ClosingTXID: closeTx.TxHash(),
|
||||||
RemotePub: &chanInfo.RemoteIdentity,
|
RemotePub: &chanInfo.RemoteIdentity,
|
||||||
Capacity: chanInfo.Capacity,
|
Capacity: chanInfo.Capacity,
|
||||||
SettledBalance: chanInfo.LocalBalance,
|
CloseType: channeldb.ForceClose,
|
||||||
TimeLockedBalance: chanInfo.LocalBalance,
|
IsPending: true,
|
||||||
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 {
|
if err := channel.DeleteState(closeInfo); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user