peer: reject remote closes with active HTLCs

In this commit, we follow up to the prior commit by ensuring we won't
accept a co-op close request for a chennel with active HTLCs. When
creating a chanCloser for the first time, we'll check the set of HTLC's
and reject a request (by sending a wire error) if the target channel
still as active HTLC's.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-03-30 13:06:57 -07:00
1 parent ecbeca5f29
commit 447a031435
2 files changed
+24 -7

No files matched your search

+2 -2
View File
@@ -1094,8 +1094,8 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
// Before we attempt the cooperative channel closure, we'll
// examine the channel to ensure that it doesn't have a
// lingering HTLC.
if len(channel.localCommit.Htlcs) != 0 {
return nil, fmt.Errorf("cannot co-op close channel " +
if len(channel.ActiveHtlcs()) != 0 {
return fmt.Errorf("cannot co-op close channel " +
"with active htlcs")
}