chancloser: report proper final local balance in ChannelCloseSummary

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.
This commit is contained in:
Olaoluwa Osuntokun 2018-01-08 17:47:30 -08:00
parent e19614ff3f
commit b11461fba7
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -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,
}