contractcourt: set auxiliary chan recovery info for all created chan close summaries

This commit is contained in:
Olaoluwa Osuntokun
2018-08-13 19:17:36 -07:00
parent c37c9db2de
commit e97e4c1f5d

View File

@@ -502,16 +502,19 @@ func (c *chainWatcher) dispatchCooperativeClose(commitSpend *chainntnfs.SpendDet
// database. We can do this as a cooperatively closed channel has all // database. We can do this as a cooperatively closed channel has all
// its outputs resolved after only one confirmation. // its outputs resolved after only one confirmation.
closeSummary := &channeldb.ChannelCloseSummary{ closeSummary := &channeldb.ChannelCloseSummary{
ChanPoint: c.cfg.chanState.FundingOutpoint, ChanPoint: c.cfg.chanState.FundingOutpoint,
ChainHash: c.cfg.chanState.ChainHash, ChainHash: c.cfg.chanState.ChainHash,
ClosingTXID: *commitSpend.SpenderTxHash, ClosingTXID: *commitSpend.SpenderTxHash,
RemotePub: c.cfg.chanState.IdentityPub, RemotePub: c.cfg.chanState.IdentityPub,
Capacity: c.cfg.chanState.Capacity, Capacity: c.cfg.chanState.Capacity,
CloseHeight: uint32(commitSpend.SpendingHeight), CloseHeight: uint32(commitSpend.SpendingHeight),
SettledBalance: localAmt, SettledBalance: localAmt,
CloseType: channeldb.CooperativeClose, CloseType: channeldb.CooperativeClose,
ShortChanID: c.cfg.chanState.ShortChanID(), ShortChanID: c.cfg.chanState.ShortChanID(),
IsPending: false, IsPending: false,
RemoteCurrentRevocation: c.cfg.chanState.RemoteCurrentRevocation,
RemoteNextRevocation: c.cfg.chanState.RemoteNextRevocation,
LocalChanConfig: c.cfg.chanState.LocalChanCfg,
} }
err := c.cfg.chanState.CloseChannel(closeSummary) err := c.cfg.chanState.CloseChannel(closeSummary)
if err != nil && err != channeldb.ErrNoActiveChannels && if err != nil && err != channeldb.ErrNoActiveChannels &&
@@ -559,15 +562,18 @@ func (c *chainWatcher) dispatchLocalForceClose(
// usage by related sub-systems. // usage by related sub-systems.
chanSnapshot := forceClose.ChanSnapshot chanSnapshot := forceClose.ChanSnapshot
closeSummary := &channeldb.ChannelCloseSummary{ closeSummary := &channeldb.ChannelCloseSummary{
ChanPoint: chanSnapshot.ChannelPoint, ChanPoint: chanSnapshot.ChannelPoint,
ChainHash: chanSnapshot.ChainHash, ChainHash: chanSnapshot.ChainHash,
ClosingTXID: forceClose.CloseTx.TxHash(), ClosingTXID: forceClose.CloseTx.TxHash(),
RemotePub: &chanSnapshot.RemoteIdentity, RemotePub: &chanSnapshot.RemoteIdentity,
Capacity: chanSnapshot.Capacity, Capacity: chanSnapshot.Capacity,
CloseType: channeldb.LocalForceClose, CloseType: channeldb.LocalForceClose,
IsPending: true, IsPending: true,
ShortChanID: c.cfg.chanState.ShortChanID(), ShortChanID: c.cfg.chanState.ShortChanID(),
CloseHeight: uint32(commitSpend.SpendingHeight), CloseHeight: uint32(commitSpend.SpendingHeight),
RemoteCurrentRevocation: c.cfg.chanState.RemoteCurrentRevocation,
RemoteNextRevocation: c.cfg.chanState.RemoteNextRevocation,
LocalChanConfig: c.cfg.chanState.LocalChanCfg,
} }
// If our commitment output isn't dust or we have active HTLC's on the // If our commitment output isn't dust or we have active HTLC's on the
@@ -739,16 +745,19 @@ func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail
// TODO(roasbeef): instead mark we got all the monies? // TODO(roasbeef): instead mark we got all the monies?
settledBalance := remoteCommit.LocalBalance.ToSatoshis() settledBalance := remoteCommit.LocalBalance.ToSatoshis()
closeSummary := channeldb.ChannelCloseSummary{ closeSummary := channeldb.ChannelCloseSummary{
ChanPoint: c.cfg.chanState.FundingOutpoint, ChanPoint: c.cfg.chanState.FundingOutpoint,
ChainHash: c.cfg.chanState.ChainHash, ChainHash: c.cfg.chanState.ChainHash,
ClosingTXID: *spendEvent.SpenderTxHash, ClosingTXID: *spendEvent.SpenderTxHash,
CloseHeight: spendHeight, CloseHeight: spendHeight,
RemotePub: c.cfg.chanState.IdentityPub, RemotePub: c.cfg.chanState.IdentityPub,
Capacity: c.cfg.chanState.Capacity, Capacity: c.cfg.chanState.Capacity,
SettledBalance: settledBalance, SettledBalance: settledBalance,
CloseType: channeldb.BreachClose, CloseType: channeldb.BreachClose,
IsPending: true, IsPending: true,
ShortChanID: c.cfg.chanState.ShortChanID(), ShortChanID: c.cfg.chanState.ShortChanID(),
RemoteCurrentRevocation: c.cfg.chanState.RemoteCurrentRevocation,
RemoteNextRevocation: c.cfg.chanState.RemoteNextRevocation,
LocalChanConfig: c.cfg.chanState.LocalChanCfg,
} }
if err := c.cfg.chanState.CloseChannel(&closeSummary); err != nil { if err := c.cfg.chanState.CloseChannel(&closeSummary); err != nil {