mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-06 22:43:12 +02:00
Merge pull request #8587 from zhiqiangxu/add_nil_check
channeldb: check return value of ReadWriteBucket
This commit is contained in:
@@ -1157,7 +1157,13 @@ func fetchFinalHtlcsBucketRw(tx kvdb.RwTx,
|
|||||||
func (c *OpenChannel) fullSync(tx kvdb.RwTx) error {
|
func (c *OpenChannel) fullSync(tx kvdb.RwTx) error {
|
||||||
// Fetch the outpoint bucket and check if the outpoint already exists.
|
// Fetch the outpoint bucket and check if the outpoint already exists.
|
||||||
opBucket := tx.ReadWriteBucket(outpointBucket)
|
opBucket := tx.ReadWriteBucket(outpointBucket)
|
||||||
|
if opBucket == nil {
|
||||||
|
return ErrNoChanDBExists
|
||||||
|
}
|
||||||
cidBucket := tx.ReadWriteBucket(chanIDBucket)
|
cidBucket := tx.ReadWriteBucket(chanIDBucket)
|
||||||
|
if cidBucket == nil {
|
||||||
|
return ErrNoChanDBExists
|
||||||
|
}
|
||||||
|
|
||||||
var chanPointBuf bytes.Buffer
|
var chanPointBuf bytes.Buffer
|
||||||
if err := writeOutpoint(&chanPointBuf, &c.FundingOutpoint); err != nil {
|
if err := writeOutpoint(&chanPointBuf, &c.FundingOutpoint); err != nil {
|
||||||
@@ -3513,6 +3519,9 @@ func (c *OpenChannel) CloseChannel(summary *ChannelCloseSummary,
|
|||||||
// Fetch the outpoint bucket to see if the outpoint exists or
|
// Fetch the outpoint bucket to see if the outpoint exists or
|
||||||
// not.
|
// not.
|
||||||
opBucket := tx.ReadWriteBucket(outpointBucket)
|
opBucket := tx.ReadWriteBucket(outpointBucket)
|
||||||
|
if opBucket == nil {
|
||||||
|
return ErrNoChanDBExists
|
||||||
|
}
|
||||||
|
|
||||||
// Add the closed outpoint to our outpoint index. This should
|
// Add the closed outpoint to our outpoint index. This should
|
||||||
// replace an open outpoint in the index.
|
// replace an open outpoint in the index.
|
||||||
|
Reference in New Issue
Block a user