Skip to content

Commit

Permalink
channeldb: check return value of ReadWriteBucket
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiangxu committed Mar 26, 2024
1 parent d3e5b2f commit 5fd46b0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions channeldb/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,13 @@ func fetchFinalHtlcsBucketRw(tx kvdb.RwTx,
func (c *OpenChannel) fullSync(tx kvdb.RwTx) error {
// Fetch the outpoint bucket and check if the outpoint already exists.
opBucket := tx.ReadWriteBucket(outpointBucket)
if opBucket == nil {
return ErrNoChanDBExists
}
cidBucket := tx.ReadWriteBucket(chanIDBucket)
if cidBucket == nil {
return ErrNoChanDBExists
}

var chanPointBuf bytes.Buffer
if err := writeOutpoint(&chanPointBuf, &c.FundingOutpoint); err != nil {
Expand Down Expand Up @@ -3513,6 +3519,9 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary,
// Fetch the outpoint bucket to see if the outpoint exists or
// not.
opBucket := tx.ReadWriteBucket(outpointBucket)
if opBucket == nil {
return ErrNoChanDBExists
}

// Add the closed outpoint to our outpoint index. This should
// replace an open outpoint in the index.
Expand Down

0 comments on commit 5fd46b0

Please sign in to comment.