Repository navigation
Scan full history on initial API restore - #710
Merged
Merged
Conversation
A failed first restore attempt leaves block hashes in storage; using their height as the stop-height cutoff on retry skipped all older history for keys discovered via gap expansion, permanently losing their transactions. Apply the cutoff only to incremental re-scans of a restored wallet, and fail the sync instead of silently dropping transactions whose block hash cannot be resolved.
abdrasulov
force-pushed
the
fix/api-restore-stop-height
branch
from
August 10, 2026 11:31
5c82784 to
2cb6e40
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes an API-restore edge case where a failed initial restore could leave partial block-hash state in storage; a retry would then incorrectly apply a height cutoff and skip older history for later-discovered keys (via gap expansion), causing permanently missing transactions and incorrect balances.
Changes:
- Apply the stop-height cutoff only after the wallet has been successfully restored (
ApiSyncStateManager.restored), so initial restores always scan full history. - Fail the sync when confirmed transaction heights cannot be resolved to block hashes, instead of silently dropping those transactions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| bitcoincore/src/main/kotlin/io/horizontalsystems/bitcoincore/apisync/blockchair/BlockchairTransactionProvider.kt | Enforces “all confirmed heights must resolve” by throwing on missing block hashes rather than filtering out transactions. |
| bitcoincore/src/main/kotlin/io/horizontalsystems/bitcoincore/apisync/blockchair/BlockchairApiSyncer.kt | Makes stopHeight nullable and only sets it for incremental re-scans after a successful initial restore. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
omurovch
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed first restore attempt (e.g. rate-limited under parallel multi-coin restore) leaves block hashes in storage; the retry then used their height as the stop-height cutoff and skipped all older history for keys discovered via gap expansion, permanently losing their transactions — observed as missing sends and an inflated balance. Apply the cutoff only to incremental re-scans of an already-restored wallet, and fail the sync instead of silently dropping transactions whose block hash cannot be resolved.
Part of horizontalsystems/unstoppable-wallet-android#9440.