From 5e48cf1273e6a84345f0c881e8350a7203f32ef7 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 4 May 2017 15:38:02 -0700 Subject: [PATCH] lnwallet: upon force close detection populate close summary --- lnwallet/channel.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 400c10fc..aded2fe5 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1001,10 +1001,20 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven walletLog.Infof("Unilateral close of ChannelPoint(%v) "+ "detected", lc.channelState.ChanID) - // As we've deleted that the channel has been closed, + // As we've detected that the channel has been closed, // immediately delete the state from disk, creating a close // summary for future usage by related sub-systems. - if err := lc.DeleteState(); err != nil { + // TODO(roasbeef): include HTLC's + closeSummary := &channeldb.ChannelCloseSummary{ + ChanPoint: *lc.channelState.ChanID, + ClosingTXID: *commitSpend.SpenderTxHash, + RemotePub: lc.channelState.IdentityPub, + Capacity: lc.Capacity, + OurBalance: lc.channelState.OurBalance, + CloseType: channeldb.ForceClose, + IsPending: true, + } + if err := lc.DeleteState(closeSummary); err != nil { walletLog.Errorf("unable to delete channel state: %v", err) }