]> Untitled Git - bdk/commit
Fix wallet sync not finding coins of addresses which are not cached
author志宇 <hello@evanlinjin.me>
Sun, 17 Jul 2022 13:02:19 +0000 (21:02 +0800)
committer志宇 <hello@evanlinjin.me>
Wed, 20 Jul 2022 15:08:12 +0000 (23:08 +0800)
commit5c940c33cb1f1a166c6e28e8bbfd9cdaef6c1ab6
tree885c2950a4a8959f4b78a6f924c3b4e76ffbf9be
parent277e18f5cb830d260ea19b5d0936f803fc782cf0
Fix wallet sync not finding coins of addresses which are not cached

Previously, electrum-based blockchain implementations only synced for
`scriptPubKey`s that are already cached in `Database`.

This PR introduces a feedback mechanism, that uses `stop_gap` and the
difference between "current index" and "last active index" to determine
whether we need to cache more `scriptPubKeys`.

The `WalletSync::wallet_setup` trait now may return an
`Error::MissingCachedScripts` error which contains the number of extra
`scriptPubKey`s to cache, in order to satisfy `stop_gap` for the next call.

`Wallet::sync` now calls `WalletSync` in a loop, cacheing inbetween
subsequent calls (if needed).
src/blockchain/esplora/reqwest.rs
src/blockchain/script_sync.rs
src/error.rs
src/testutils/blockchain_tests.rs
src/testutils/configurable_blockchain_tests.rs
src/wallet/mod.rs