From 9fd73af589267679b7afb8834e75ac6219507def Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 27 Mar 2018 17:05:22 -0700 Subject: [PATCH] channeldb: update chanid in-mem during MarkAsOpen Modifies the MarkAsOpen operation to also update the ShortChanID and IsPending fields in-memory. Before, only the on-disk representation was updated, which may have lead to stale data channel states being passed in-memory. --- channeldb/channel.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/channeldb/channel.go b/channeldb/channel.go index 6d58f8ab5..764db9a72 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -538,7 +538,7 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error { c.Lock() defer c.Unlock() - return c.Db.Update(func(tx *bolt.Tx) error { + if err := c.Db.Update(func(tx *bolt.Tx) error { chanBucket, err := updateChanBucket(tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash) if err != nil { @@ -554,7 +554,14 @@ func (c *OpenChannel) MarkAsOpen(openLoc lnwire.ShortChannelID) error { channel.ShortChanID = openLoc return putOpenChannel(chanBucket, channel) - }) + }); err != nil { + return err + } + + c.IsPending = false + c.ShortChanID = openLoc + + return nil } // MarkBorked marks the event when the channel as reached an irreconcilable