Prevent wallet from rescanning beyond prune depth #751
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.
This PR replaces #532 and is built on top of #749.
Once #749 is merged, the wallet will be able to determine whether the node it's connected to is pruned (whether its running as a plugin or standalone service). The prune depth is hard coded in
networks.js
for each network, so a wallet can prevent the user from rescanning more blocks than are available on disk.Currently in bcoin, the rescanning process starts with a walletDB rollback (effectively "unconfirming" all the transactions in the DB from the rescan height to the tip), and THEN it scans the blockchain from the given height. If the given rescan height is lower than
tip height - prune depth
, those blocks will never be scanned and therefore the wallet will be out of sync with the state of the full blockchain.This PR will throw if the user has requested a rescan beyond the available blocks on disk. The check is added to
walletDB
but is also added to wallethttp
-- the reason the http check is needed in addition is because the http call returnssuccess: true
before rescanning begins (since in practice its a background process).Finally, to make testing more practical the regtest pruning settings have been lowered significantly. Added to the changelog is this message: