rpcserver: only block co-op close for frozen chans
This commit fixes a recent issue from #4081 that would prevent a frozen channel from being force closed via the rpc. We correct this, so that only the co-op path is inhibited.
This commit is contained in:
parent
3c371dd633
commit
d1fa33c8eb
22
rpcserver.go
22
rpcserver.go
@ -1990,19 +1990,12 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a frozen channel, then we only allow the close to proceed
|
// Retrieve the best height of the chain, which we'll use to complete
|
||||||
// if we were the responder to this channel.
|
// either closing flow.
|
||||||
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if channel.ChanType.IsFrozen() && channel.IsInitiator &&
|
|
||||||
uint32(bestHeight) < channel.ThawHeight {
|
|
||||||
|
|
||||||
return fmt.Errorf("cannot co-op close frozen channel as "+
|
|
||||||
"initiator until height=%v, (current_height=%v)",
|
|
||||||
channel.ThawHeight, bestHeight)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a force closure was requested, then we'll handle all the details
|
// If a force closure was requested, then we'll handle all the details
|
||||||
// around the creation and broadcast of the unilateral closure
|
// around the creation and broadcast of the unilateral closure
|
||||||
@ -2057,6 +2050,17 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
// If this is a frozen channel, then we only allow the co-op
|
||||||
|
// close to proceed if we were the responder to this channel.
|
||||||
|
if channel.ChanType.IsFrozen() && channel.IsInitiator &&
|
||||||
|
uint32(bestHeight) < channel.ThawHeight {
|
||||||
|
|
||||||
|
return fmt.Errorf("cannot co-op close frozen channel "+
|
||||||
|
"as initiator until height=%v, "+
|
||||||
|
"(current_height=%v)", channel.ThawHeight,
|
||||||
|
bestHeight)
|
||||||
|
}
|
||||||
|
|
||||||
// If the link is not known by the switch, we cannot gracefully close
|
// If the link is not known by the switch, we cannot gracefully close
|
||||||
// the channel.
|
// the channel.
|
||||||
channelID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
channelID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
Loading…
Reference in New Issue
Block a user