Skip to content

Commit

Permalink
wallet: make sure the bucket is not nil to avoid panic
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Nov 4, 2024
1 parent 321c0f3 commit 2091fa7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions wallet/chainntfns.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package wallet

import (
"bytes"
"errors"
"time"

"github.com/btcsuite/btcd/chaincfg/chainhash"
Expand Down Expand Up @@ -242,6 +243,9 @@ func (w *Wallet) handleChainNotifications() {
// the passed block.
func (w *Wallet) connectBlock(dbtx walletdb.ReadWriteTx, b wtxmgr.BlockMeta) error {
addrmgrNs := dbtx.ReadWriteBucket(waddrmgrNamespaceKey)
if addrmgrNs == nil {
return errors.New("empty waddrmgr bucket")

Check failure on line 247 in wallet/chainntfns.go

View workflow job for this annotation

GitHub Actions / Format, compilation and lint check

do not define dynamic errors, use wrapped static errors instead: "errors.New(\"empty waddrmgr bucket\")" (err113)
}

bs := waddrmgr.BlockStamp{
Height: b.Height,
Expand Down

0 comments on commit 2091fa7

Please sign in to comment.