From 2091fa78122ac6f4834c8fd2983e65383ff8c6c0 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Mon, 4 Nov 2024 17:19:32 +0800 Subject: [PATCH] wallet: make sure the bucket is not nil to avoid panic --- wallet/chainntfns.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wallet/chainntfns.go b/wallet/chainntfns.go index a902fcd4bf..f145c3ee13 100644 --- a/wallet/chainntfns.go +++ b/wallet/chainntfns.go @@ -6,6 +6,7 @@ package wallet import ( "bytes" + "errors" "time" "github.com/btcsuite/btcd/chaincfg/chainhash" @@ -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") + } bs := waddrmgr.BlockStamp{ Height: b.Height,