mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-31 19:06:10 +02:00
Merge #15870: wallet: Only fail rescan when blocks have actually been pruned
fa7e311e16[doc] rpcwallet: Only fail rescan when blocks have been pruned (MarcoFalke)aaaa57c2aascripted-diff: Bump copyright headers in wallet (MarcoFalke)faf3729242wallet: Only fail rescan when blocks have actually been pruned (MarcoFalke) Pull request description: This brings the behaviour of the import* calls closer to importmulti. After this change, the difference between importmulti and the other import* calls is * that in importmulti you can "opt-out" of scanning early blocks by setting a later timestamp. * that in importmulti the wallet will successfully import the data, but fail to rescan. Whereas in the other calls, the wallet will abort before importing the data. ACKs for commit fa7e31: promag: utACKfa7e311e16. jnewbery: utACKfa7e311e16Tree-SHA512: a57d52ffea94b64e0eb9b5d3a7a63031325833908297dd14eb0c5251ffea3b2113b131003f1db4e9599e014369165a57f107a7150bb65e4c791e5fe742f33cb8
This commit is contained in:
@@ -4209,10 +4209,13 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
||||
|
||||
if (tip_height && *tip_height != rescan_height)
|
||||
{
|
||||
//We can't rescan beyond non-pruned blocks, stop and throw an error
|
||||
//this might happen if a user uses an old wallet within a pruned node
|
||||
// or if he ran -disablewallet for a longer time, then decided to re-enable
|
||||
if (chain.getPruneMode()) {
|
||||
// We can't rescan beyond non-pruned blocks, stop and throw an error.
|
||||
// This might happen if a user uses an old wallet within a pruned node
|
||||
// or if they ran -disablewallet for a longer time, then decided to re-enable
|
||||
if (chain.havePruned()) {
|
||||
// Exit early and print an error.
|
||||
// If a block is pruned after this check, we will load the wallet,
|
||||
// but fail the rescan with a generic error.
|
||||
int block_height = *tip_height;
|
||||
while (block_height > 0 && locked_chain->haveBlockOnDisk(block_height - 1) && rescan_height != block_height) {
|
||||
--block_height;
|
||||
|
||||
Reference in New Issue
Block a user