mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
peer: check for existence of channel when handling a remote close
This commit patches a bug in the code for handling a remote cooperative channel closer. Previous if the region node didn’t know of the channel which was being requested to close, then a panic would occur as the entry read from the map would be nil. To fix this bug, we now ensure that the channel exists before we perform any actions on it. In a later commit which overhauls the channel opening and closing to match that of the specification, this logic will be modified to properly send an error message in response to the failed channel closure.
This commit is contained in:
parent
5889331422
commit
906c0451c8
7
peer.go
7
peer.go
@ -910,8 +910,13 @@ func (p *peer) handleRemoteClose(req *lnwire.CloseRequest) {
|
||||
}
|
||||
|
||||
p.activeChanMtx.RLock()
|
||||
channel := p.activeChannels[key]
|
||||
channel, ok := p.activeChannels[key]
|
||||
p.activeChanMtx.RUnlock()
|
||||
if !ok {
|
||||
peerLog.Errorf("unable to close channel, ChannelPoint(%v) is "+
|
||||
"unknown", key)
|
||||
return
|
||||
}
|
||||
|
||||
// Now that we have their signature for the closure transaction, we
|
||||
// can assemble the final closure transaction, complete with our
|
||||
|
Loading…
Reference in New Issue
Block a user