contractcourt/chain_watcher: add channel sync message to CloseChannelSummary

This commit is contained in:
Johan T. Halseth 2018-11-20 15:09:45 +01:00
parent 676a1b1407
commit a9f93b2988
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 36 additions and 0 deletions

@ -522,6 +522,15 @@ func (c *chainWatcher) dispatchCooperativeClose(commitSpend *chainntnfs.SpendDet
LocalChanConfig: c.cfg.chanState.LocalChanCfg, LocalChanConfig: c.cfg.chanState.LocalChanCfg,
} }
// Attempt to add a channel sync message to the close summary.
chanSync, err := lnwallet.ChanSyncMsg(c.cfg.chanState)
if err != nil {
log.Errorf("ChannelPoint(%v): unable to create channel sync "+
"message: %v", c.cfg.chanState.FundingOutpoint, err)
} else {
closeSummary.LastChanSyncMsg = chanSync
}
// Create a summary of all the information needed to handle the // Create a summary of all the information needed to handle the
// cooperative closure. // cooperative closure.
closeInfo := &CooperativeCloseInfo{ closeInfo := &CooperativeCloseInfo{
@ -590,6 +599,15 @@ func (c *chainWatcher) dispatchLocalForceClose(
closeSummary.TimeLockedBalance += htlcValue closeSummary.TimeLockedBalance += htlcValue
} }
// Attempt to add a channel sync message to the close summary.
chanSync, err := lnwallet.ChanSyncMsg(c.cfg.chanState)
if err != nil {
log.Errorf("ChannelPoint(%v): unable to create channel sync "+
"message: %v", c.cfg.chanState.FundingOutpoint, err)
} else {
closeSummary.LastChanSyncMsg = chanSync
}
// With the event processed, we'll now notify all subscribers of the // With the event processed, we'll now notify all subscribers of the
// event. // event.
closeInfo := &LocalUnilateralCloseInfo{ closeInfo := &LocalUnilateralCloseInfo{
@ -749,6 +767,15 @@ func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail
LocalChanConfig: c.cfg.chanState.LocalChanCfg, LocalChanConfig: c.cfg.chanState.LocalChanCfg,
} }
// Attempt to add a channel sync message to the close summary.
chanSync, err := lnwallet.ChanSyncMsg(c.cfg.chanState)
if err != nil {
log.Errorf("ChannelPoint(%v): unable to create channel sync "+
"message: %v", c.cfg.chanState.FundingOutpoint, err)
} else {
closeSummary.LastChanSyncMsg = chanSync
}
if err := c.cfg.chanState.CloseChannel(&closeSummary); err != nil { if err := c.cfg.chanState.CloseChannel(&closeSummary); err != nil {
return err return err
} }

@ -5116,6 +5116,15 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, signer Signer,
LocalChanConfig: chanState.LocalChanCfg, LocalChanConfig: chanState.LocalChanCfg,
} }
// Attempt to add a channel sync message to the close summary.
chanSync, err := ChanSyncMsg(chanState)
if err != nil {
walletLog.Errorf("ChannelPoint(%v): unable to create channel sync "+
"message: %v", chanState.FundingOutpoint, err)
} else {
closeSummary.LastChanSyncMsg = chanSync
}
return &UnilateralCloseSummary{ return &UnilateralCloseSummary{
SpendDetail: commitSpend, SpendDetail: commitSpend,
ChannelCloseSummary: closeSummary, ChannelCloseSummary: closeSummary,