From 3c1d19e1adbeaaeb6cd827a4dd2e7686cc201dd4 Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Thu, 21 Dec 2023 14:49:29 -0300 Subject: [PATCH] wallet: Fix off-by-one in addr discovery This fixes an off-by-one in sizing the backing array for cfilter data during address discovery. During address discovery, the GetMainChainCFilters call to fetch cfilters from the DB uses an array sized by the caller to put the data. However, due to being an inclusive fetch, the call in the address finder is not correctly sized, missing one (i.e. the last) block. This could cause an issue when the wallet had a single address used and that address was used on a transaction on the wallet's tip, causing the wallet to miss that address being used. --- wallet/discovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet/discovery.go b/wallet/discovery.go index ef5fa03fc..3dbdc22cf 100644 --- a/wallet/discovery.go +++ b/wallet/discovery.go @@ -184,7 +184,7 @@ func (a *addrFinder) find(ctx context.Context, start *chainhash.Hash, p Peer) er return err } _, tipHeight := a.w.txStore.MainChainTip(dbtx) - storage := make([]*udb.BlockCFilter, tipHeight-int32(h.Height)) + storage := make([]*udb.BlockCFilter, tipHeight-int32(h.Height)+1) fs, err = a.w.txStore.GetMainChainCFilters(dbtx, start, true, storage) return err })