From 3875754e0f306e28212383f725c885fc3f5747d4 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 10 Nov 2017 19:31:47 -0800 Subject: [PATCH] channeldb: also update chanInfo when updating commitment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we fix an existing bug wherein we failed to update the channels state once we accepted a new commitment. As a result, after a state transition, if the channel state was read from disk, values like TotalMSatSent wouldn’t be properly updated. --- channeldb/channel.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/channeldb/channel.go b/channeldb/channel.go index 925b4353d..01b36ce5f 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -629,9 +629,19 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *ChannelCommitment) error { return err } + if err = putChanInfo(chanBucket, c); err != nil { + return fmt.Errorf("unable to store chan info: %v", err) + } + // With the proper bucket fetched, we'll now write toe latest // commitment state to dis for the target party. - return putChanCommitment(chanBucket, newCommitment, true) + err = putChanCommitment(chanBucket, newCommitment, true) + if err != nil { + return fmt.Errorf("unable to store chan "+ + "revocations: %v", err) + } + + return nil }) if err != nil { return err