lnwallet: upon force close detection populate close summary

This commit is contained in:
Olaoluwa Osuntokun 2017-05-04 15:38:02 -07:00
parent be583306ab
commit 5e48cf1273
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 12 additions and 2 deletions

View File

@ -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)
}