mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
rpc: Include assumeutxo as a failure reason of rescanblockchain
This commit is contained in:
parent
595edee169
commit
9d2d9f7ce2
2 changed files with 13 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
#include <policy/rbf.h>
|
#include <policy/rbf.h>
|
||||||
#include <rpc/util.h>
|
#include <rpc/util.h>
|
||||||
|
#include <rpc/blockchain.h>
|
||||||
#include <util/vector.h>
|
#include <util/vector.h>
|
||||||
#include <wallet/receive.h>
|
#include <wallet/receive.h>
|
||||||
#include <wallet/rpc/util.h>
|
#include <wallet/rpc/util.h>
|
||||||
|
@ -909,10 +910,16 @@ RPCHelpMan rescanblockchain()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't rescan beyond non-pruned blocks, stop and throw an error
|
// We can't rescan unavailable blocks, stop and throw an error
|
||||||
if (!pwallet->chain().hasBlocks(pwallet->GetLastBlockHash(), start_height, stop_height)) {
|
if (!pwallet->chain().hasBlocks(pwallet->GetLastBlockHash(), start_height, stop_height)) {
|
||||||
|
if (pwallet->chain().havePruned() && pwallet->chain().getPruneHeight() >= start_height) {
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
|
throw JSONRPCError(RPC_MISC_ERROR, "Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
|
||||||
}
|
}
|
||||||
|
if (pwallet->chain().hasAssumedValidChain()) {
|
||||||
|
throw JSONRPCError(RPC_MISC_ERROR, "Failed to rescan unavailable blocks likely due to an in-progress assumeutxo background sync. Check logs or getchainstates RPC for assumeutxo background sync progress and try again later.");
|
||||||
|
}
|
||||||
|
throw JSONRPCError(RPC_MISC_ERROR, "Failed to rescan unavailable blocks, potentially caused by data corruption. If the issue persists you may want to reindex (see -reindex option).");
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_NONFATAL(pwallet->chain().findAncestorByHeight(pwallet->GetLastBlockHash(), start_height, FoundBlock().hash(start_block)));
|
CHECK_NONFATAL(pwallet->chain().findAncestorByHeight(pwallet->GetLastBlockHash(), start_height, FoundBlock().hash(start_block)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,10 @@ class AssumeutxoTest(BitcoinTestFramework):
|
||||||
assert_equal(result[0]['error']['code'], -1)
|
assert_equal(result[0]['error']['code'], -1)
|
||||||
assert_equal(result[0]['error']['message'], expected_error_message)
|
assert_equal(result[0]['error']['message'], expected_error_message)
|
||||||
|
|
||||||
|
self.log.info("Test that rescanning blocks from before the snapshot fails when blocks are not available from the background sync yet")
|
||||||
|
w1 = n1.get_wallet_rpc(wallet_name)
|
||||||
|
assert_raises_rpc_error(-1, "Failed to rescan unavailable blocks likely due to an in-progress assumeutxo background sync. Check logs or getchainstates RPC for assumeutxo background sync progress and try again later.", w1.rescanblockchain, 100)
|
||||||
|
|
||||||
PAUSE_HEIGHT = FINAL_HEIGHT - 40
|
PAUSE_HEIGHT = FINAL_HEIGHT - 40
|
||||||
|
|
||||||
self.log.info("Restarting node to stop at height %d", PAUSE_HEIGHT)
|
self.log.info("Restarting node to stop at height %d", PAUSE_HEIGHT)
|
||||||
|
|
Loading…
Add table
Reference in a new issue