Skip to content

Commit

Permalink
wallet: Fix off-by-one in addr discovery
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matheusd committed Dec 21, 2023
1 parent b9fd1a7 commit 3c1d19e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wallet/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit 3c1d19e

Please sign in to comment.