From b11461fba79ae701c09d806d384d69fc3859f4d9 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 8 Jan 2018 17:47:30 -0800 Subject: [PATCH] chancloser: report proper final local balance in ChannelCloseSummary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this commit, the final close summary we added to the database for the initiator of the channel was incorrect. This is due to the fact that before, we would use the final snapshot to determine how many coins the local party was delivered as a result of the cooperative closure transaction. This is incorrect, as the local party pays fees on the closure transaction if it’s the initiator. To remedy this, we’ll now use the new return value of CompleteCooperativeClose to properly note our final balance in the database. --- chancloser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chancloser.go b/chancloser.go index 57f8b9a4b..a64e81f46 100644 --- a/chancloser.go +++ b/chancloser.go @@ -416,7 +416,7 @@ func (c *channelCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, b remoteSig := append( closeSignedMsg.Signature.Serialize(), byte(txscript.SigHashAll), ) - closeTx, err := c.cfg.channel.CompleteCooperativeClose( + closeTx, finalLocalBalance, err := c.cfg.channel.CompleteCooperativeClose( localSig, remoteSig, c.localDeliveryScript, c.remoteDeliveryScript, remoteProposedFee, ) @@ -465,7 +465,7 @@ func (c *channelCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, b ClosingTXID: closingTxid, RemotePub: &chanInfo.RemoteIdentity, Capacity: chanInfo.Capacity, - SettledBalance: chanInfo.LocalBalance.ToSatoshis(), + SettledBalance: finalLocalBalance, CloseType: channeldb.CooperativeClose, IsPending: true, }