From 73641d222f6ef40cf605f59238e11da5fc261823 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 20 Jan 2018 20:26:15 -0800 Subject: [PATCH] contractcourt: properly use the broadcast state number during breach remedy --- contractcourt/chain_watcher.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go index 0371490c..f7030db4 100644 --- a/contractcourt/chain_watcher.go +++ b/contractcourt/chain_watcher.go @@ -367,6 +367,7 @@ func (c *chainWatcher) closeObserver(spendNtfn *chainntnfs.SpendEvent) { case broadcastStateNum < remoteStateNum: if err := c.dispatchContractBreach( commitSpend, remoteCommit, + broadcastStateNum, ); err != nil { log.Errorf("unable to handle channel "+ "breach for chan_point=%v: %v", @@ -549,11 +550,12 @@ func (c *chainWatcher) dispatchRemoteClose(commitSpend *chainntnfs.SpendDetail, // materials required to bring the cheater to justice, then notify all // registered subscribers of this event. func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail, - remoteCommit *channeldb.ChannelCommitment) error { + remoteCommit *channeldb.ChannelCommitment, + broadcastStateNum uint64) error { log.Warnf("Remote peer has breached the channel contract for "+ "ChannelPoint(%v). Revoked state #%v was broadcast!!!", - c.chanState.FundingOutpoint, remoteCommit.CommitHeight) + c.chanState.FundingOutpoint, broadcastStateNum) if err := c.chanState.MarkBorked(); err != nil { return fmt.Errorf("unable to mark channel as borked: %v", err)