contractcourt: properly use the broadcast state number during breach remedy

This commit is contained in:
Olaoluwa Osuntokun 2018-01-20 20:26:15 -08:00
parent 5df6704a9c
commit 73641d222f
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 4 additions and 2 deletions

View File

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