From 4fe174ba4e0ea200f826c3e5ae6ccfedb7a49b72 Mon Sep 17 00:00:00 2001 From: nsa Date: Mon, 9 Mar 2020 13:36:33 -0400 Subject: [PATCH] htlcswitch: switch ackDownStreamPackets order with contract update call This commit modifies updateCommitTx to error with ErrLinkShuttingDown when we try to send a ContractUpdate on the htlcUpdates chan and the link has closed the quit chan. It also changes the order of the call to ackDownStreamPackets and contract update call for consistency since the packets should be acknowledged before the link goes down. --- htlcswitch/link.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 7c834827..cac199b6 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -2060,6 +2060,10 @@ func (l *channelLink) updateCommitTx() error { return err } + if err := l.ackDownStreamPackets(); err != nil { + return err + } + // The remote party now has a new pending commitment, so we'll update // the contract court to be aware of this new set (the prior old remote // pending). @@ -2069,11 +2073,7 @@ func (l *channelLink) updateCommitTx() error { Htlcs: pendingHTLCs, }: case <-l.quit: - return nil - } - - if err := l.ackDownStreamPackets(); err != nil { - return err + return ErrLinkShuttingDown } commitSig := &lnwire.CommitSig{