btcsuite / btcwallet

A secure bitcoin wallet daemon written in Go (golang)
ISC License
1.15k stars 590 forks source link

chain: use neutrino filters to speed up bitcoind seed recovery #889

Open Roasbeef opened 1 year ago

Roasbeef commented 1 year ago

In this commit, we use neutrino filters to speed up bitcoind seed recovery. We use the recently created maybeShouldFetchBlock function to check the filters to see if we need to fetch a block at all. This saves us from fetching, decoding, then scanning the block contents if we know nothing is present in them.

At this point, we can also further consolidate the FilterBlocks methods between the two backends, as they're now identical.

Another follow up here would be to start to prefetch both filters and blocks. We know that we'll need to fetch every filter, so we can fetch them all in a single RPC request (batch call). Once we have the filters, we can sort of check them all in parallel, but need to mind the FoundOutPoints field, as once we have something like a change addr we know of, we want to then watch that for subsequent spends.