lnd: avoid wiping a channel twice

This commit is contained in:
Olaoluwa Osuntokun 2016-09-12 19:04:08 -07:00
parent 39044cb2fa
commit ff70b3afa9
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -823,7 +823,11 @@ func wipeChannel(p *peer, channel *lnwallet.LightningChannel) error {
// Instruct the Htlc Switch to close this link as the channel is no
// longer active.
p.server.htlcSwitch.UnregisterLink(p.lightningID, chanID)
htlcWireLink := p.htlcManagers[*chanID]
htlcWireLink, ok := p.htlcManagers[*chanID]
if !ok {
return nil
}
delete(p.htlcManagers, *chanID)
close(htlcWireLink)
@ -925,6 +929,7 @@ out:
for {
select {
case <-channel.UnilateralCloseSignal:
// TODO(roasbeef): eliminate false positive via local close
peerLog.Warnf("Remote peer has closed ChannelPoint(%v) on-chain",
state.chanPoint)
if err := wipeChannel(p, channel); err != nil {