mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Remove -rescan startup parameter
This commit is contained in:
parent
f963b0fa8c
commit
bccd1d942d
12 changed files with 26 additions and 36 deletions
|
@ -157,7 +157,7 @@
|
||||||
#coinstatsindex=1
|
#coinstatsindex=1
|
||||||
|
|
||||||
# Enable pruning to reduce storage requirements by deleting old blocks.
|
# Enable pruning to reduce storage requirements by deleting old blocks.
|
||||||
# This mode is incompatible with -txindex, -coinstatsindex and -rescan.
|
# This mode is incompatible with -txindex and -coinstatsindex.
|
||||||
# 0 = default (no pruning).
|
# 0 = default (no pruning).
|
||||||
# 1 = allows manual pruning via RPC.
|
# 1 = allows manual pruning via RPC.
|
||||||
# >=550 = target to stay under in MiB.
|
# >=550 = target to stay under in MiB.
|
||||||
|
|
|
@ -39,7 +39,6 @@ void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
|
||||||
"-maxtxfee=<amt>",
|
"-maxtxfee=<amt>",
|
||||||
"-mintxfee=<amt>",
|
"-mintxfee=<amt>",
|
||||||
"-paytxfee=<amt>",
|
"-paytxfee=<amt>",
|
||||||
"-rescan",
|
|
||||||
"-signer=<cmd>",
|
"-signer=<cmd>",
|
||||||
"-spendzeroconfchange",
|
"-spendzeroconfchange",
|
||||||
"-txconfirmtarget=<n>",
|
"-txconfirmtarget=<n>",
|
||||||
|
|
|
@ -397,7 +397,7 @@ void SetupServerArgs(ArgsManager& argsman)
|
||||||
-GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
-GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
argsman.AddArg("-persistmempool", strprintf("Whether to save the mempool on shutdown and load on restart (default: %u)", DEFAULT_PERSIST_MEMPOOL), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-persistmempool", strprintf("Whether to save the mempool on shutdown and load on restart (default: %u)", DEFAULT_PERSIST_MEMPOOL), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
argsman.AddArg("-pid=<file>", strprintf("Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: %s)", BITCOIN_PID_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-pid=<file>", strprintf("Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: %s)", BITCOIN_PID_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
argsman.AddArg("-prune=<n>", strprintf("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex, -coinstatsindex and -rescan. "
|
argsman.AddArg("-prune=<n>", strprintf("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -coinstatsindex. "
|
||||||
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
|
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
|
||||||
"(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >=%u = automatically prune block files to stay under the specified target size in MiB)", MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
"(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >=%u = automatically prune block files to stay under the specified target size in MiB)", MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
argsman.AddArg("-reindex", "Rebuild chain state and block index from the blk*.dat files on disk", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-reindex", "Rebuild chain state and block index from the blk*.dat files on disk", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
|
|
|
@ -62,7 +62,6 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
|
||||||
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
argsman.AddArg("-paytxfee=<amt>", strprintf("Fee rate (in %s/kvB) to add to transactions you send (default: %s)",
|
argsman.AddArg("-paytxfee=<amt>", strprintf("Fee rate (in %s/kvB) to add to transactions you send (default: %s)",
|
||||||
CURRENCY_UNIT, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
CURRENCY_UNIT, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
argsman.AddArg("-rescan", "Rescan the block chain for missing wallet transactions on startup", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
|
||||||
#ifdef ENABLE_EXTERNAL_SIGNER
|
#ifdef ENABLE_EXTERNAL_SIGNER
|
||||||
argsman.AddArg("-signer=<cmd>", "External signing tool, see doc/external-signer.md", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
argsman.AddArg("-signer=<cmd>", "External signing tool, see doc/external-signer.md", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1439,7 +1439,7 @@ RPCHelpMan importmulti()
|
||||||
"and coins using this key may not appear in the wallet. This error could be "
|
"and coins using this key may not appear in the wallet. This error could be "
|
||||||
"caused by pruning or data corruption (see bitcoind log for details) and could "
|
"caused by pruning or data corruption (see bitcoind log for details) and could "
|
||||||
"be dealt with by downloading and rescanning the relevant blocks (see -reindex "
|
"be dealt with by downloading and rescanning the relevant blocks (see -reindex "
|
||||||
"and -rescan options).",
|
"option and rescanblockchain RPC).",
|
||||||
GetImportTimestamp(request, now), scannedTime - TIMESTAMP_WINDOW - 1, TIMESTAMP_WINDOW)));
|
GetImportTimestamp(request, now), scannedTime - TIMESTAMP_WINDOW - 1, TIMESTAMP_WINDOW)));
|
||||||
response.push_back(std::move(result));
|
response.push_back(std::move(result));
|
||||||
}
|
}
|
||||||
|
@ -1744,7 +1744,7 @@ RPCHelpMan importdescriptors()
|
||||||
"and coins using this desc may not appear in the wallet. This error could be "
|
"and coins using this desc may not appear in the wallet. This error could be "
|
||||||
"caused by pruning or data corruption (see bitcoind log for details) and could "
|
"caused by pruning or data corruption (see bitcoind log for details) and could "
|
||||||
"be dealt with by downloading and rescanning the relevant blocks (see -reindex "
|
"be dealt with by downloading and rescanning the relevant blocks (see -reindex "
|
||||||
"and -rescan options).",
|
"option and rescanblockchain RPC).",
|
||||||
GetImportTimestamp(request, now), scanned_time - TIMESTAMP_WINDOW - 1, TIMESTAMP_WINDOW)));
|
GetImportTimestamp(request, now), scanned_time - TIMESTAMP_WINDOW - 1, TIMESTAMP_WINDOW)));
|
||||||
response.push_back(std::move(result));
|
response.push_back(std::move(result));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2632,7 +2632,7 @@ static RPCHelpMan loadwallet()
|
||||||
return RPCHelpMan{"loadwallet",
|
return RPCHelpMan{"loadwallet",
|
||||||
"\nLoads a wallet from a wallet file or directory."
|
"\nLoads a wallet from a wallet file or directory."
|
||||||
"\nNote that all wallet command-line options used when starting bitcoind will be"
|
"\nNote that all wallet command-line options used when starting bitcoind will be"
|
||||||
"\napplied to the new wallet (eg -rescan, etc).\n",
|
"\napplied to the new wallet.\n",
|
||||||
{
|
{
|
||||||
{"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet directory or .dat file."},
|
{"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet directory or .dat file."},
|
||||||
{"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
|
{"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
|
||||||
// Call Salvage with fAggressive=true to
|
// Call Salvage with fAggressive=true to
|
||||||
// get as much data as possible.
|
// get as much data as possible.
|
||||||
// Rewrite salvaged data to fresh wallet file
|
// Rewrite salvaged data to fresh wallet file
|
||||||
// Set -rescan so any missing transactions will be
|
// Rescan so any missing transactions will be
|
||||||
// found.
|
// found.
|
||||||
int64_t now = GetTime();
|
int64_t now = GetTime();
|
||||||
std::string newFilename = strprintf("%s.%d.bak", filename, now);
|
std::string newFilename = strprintf("%s.%d.bak", filename, now);
|
||||||
|
|
|
@ -232,8 +232,8 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
|
||||||
"seconds of key creation, and could contain transactions pertaining to the key. As a result, "
|
"seconds of key creation, and could contain transactions pertaining to the key. As a result, "
|
||||||
"transactions and coins using this key may not appear in the wallet. This error could be caused "
|
"transactions and coins using this key may not appear in the wallet. This error could be caused "
|
||||||
"by pruning or data corruption (see bitcoind log for details) and could be dealt with by "
|
"by pruning or data corruption (see bitcoind log for details) and could be dealt with by "
|
||||||
"downloading and rescanning the relevant blocks (see -reindex and -rescan "
|
"downloading and rescanning the relevant blocks (see -reindex option and rescanblockchain "
|
||||||
"options).\"}},{\"success\":true}]",
|
"RPC).\"}},{\"success\":true}]",
|
||||||
0, oldTip->GetBlockTimeMax(), TIMESTAMP_WINDOW));
|
0, oldTip->GetBlockTimeMax(), TIMESTAMP_WINDOW));
|
||||||
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt);
|
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1600,7 +1600,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
||||||
WalletLogPrintf("Rescan started from block %s...\n", start_block.ToString());
|
WalletLogPrintf("Rescan started from block %s...\n", start_block.ToString());
|
||||||
|
|
||||||
fAbortRescan = false;
|
fAbortRescan = false;
|
||||||
ShowProgress(strprintf("%s " + _("Rescanning…").translated, GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
|
ShowProgress(strprintf("%s " + _("Rescanning…").translated, GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption)
|
||||||
uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash());
|
uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash());
|
||||||
uint256 end_hash = tip_hash;
|
uint256 end_hash = tip_hash;
|
||||||
if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash));
|
if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash));
|
||||||
|
@ -2794,9 +2794,9 @@ bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interf
|
||||||
// interface.
|
// interface.
|
||||||
walletInstance->m_chain_notifications_handler = walletInstance->chain().handleNotifications(walletInstance);
|
walletInstance->m_chain_notifications_handler = walletInstance->chain().handleNotifications(walletInstance);
|
||||||
|
|
||||||
// If either rescan_required = true or -rescan is set, rescan_height remains equal to 0
|
// If rescan_required = true, rescan_height remains equal to 0
|
||||||
int rescan_height = 0;
|
int rescan_height = 0;
|
||||||
if (!rescan_required && !gArgs.GetBoolArg("-rescan", false))
|
if (!rescan_required)
|
||||||
{
|
{
|
||||||
WalletBatch batch(walletInstance->GetDatabase());
|
WalletBatch batch(walletInstance->GetDatabase());
|
||||||
CBlockLocator locator;
|
CBlockLocator locator;
|
||||||
|
|
|
@ -42,7 +42,6 @@ class NotificationsTest(BitcoinTestFramework):
|
||||||
f"-alertnotify=echo > {os.path.join(self.alertnotify_dir, '%s')}",
|
f"-alertnotify=echo > {os.path.join(self.alertnotify_dir, '%s')}",
|
||||||
f"-blocknotify=echo > {os.path.join(self.blocknotify_dir, '%s')}",
|
f"-blocknotify=echo > {os.path.join(self.blocknotify_dir, '%s')}",
|
||||||
], [
|
], [
|
||||||
"-rescan",
|
|
||||||
f"-walletnotify=echo %h_%b > {os.path.join(self.walletnotify_dir, notify_outputname('%w', '%s'))}",
|
f"-walletnotify=echo %h_%b > {os.path.join(self.walletnotify_dir, notify_outputname('%w', '%s'))}",
|
||||||
]]
|
]]
|
||||||
self.wallet_names = [self.default_wallet_name, self.wallet]
|
self.wallet_names = [self.default_wallet_name, self.wallet]
|
||||||
|
@ -91,16 +90,15 @@ class NotificationsTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# directory content should equal the generated transaction hashes
|
# directory content should equal the generated transaction hashes
|
||||||
tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count)))
|
tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count)))
|
||||||
self.stop_node(1)
|
|
||||||
self.expect_wallet_notify(tx_details)
|
self.expect_wallet_notify(tx_details)
|
||||||
|
|
||||||
self.log.info("test -walletnotify after rescan")
|
self.log.info("test -walletnotify after rescan")
|
||||||
# restart node to rescan to force wallet notifications
|
# rescan to force wallet notifications
|
||||||
self.start_node(1)
|
self.nodes[1].rescanblockchain()
|
||||||
self.connect_nodes(0, 1)
|
|
||||||
|
|
||||||
self.wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)
|
self.wait_until(lambda: len(os.listdir(self.walletnotify_dir)) == block_count, timeout=10)
|
||||||
|
|
||||||
|
self.connect_nodes(0, 1)
|
||||||
|
|
||||||
# directory content should equal the generated transaction hashes
|
# directory content should equal the generated transaction hashes
|
||||||
tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count)))
|
tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count)))
|
||||||
self.expect_wallet_notify(tx_details)
|
self.expect_wallet_notify(tx_details)
|
||||||
|
|
|
@ -582,23 +582,17 @@ class WalletTest(BitcoinTestFramework):
|
||||||
assert label in self.nodes[0].listlabels()
|
assert label in self.nodes[0].listlabels()
|
||||||
self.nodes[0].rpc.ensure_ascii = True # restore to default
|
self.nodes[0].rpc.ensure_ascii = True # restore to default
|
||||||
|
|
||||||
# maintenance tests
|
# -reindex tests
|
||||||
maintenance = [
|
|
||||||
'-rescan',
|
|
||||||
'-reindex',
|
|
||||||
]
|
|
||||||
chainlimit = 6
|
chainlimit = 6
|
||||||
for m in maintenance:
|
self.log.info("Test -reindex")
|
||||||
self.log.info("Test " + m)
|
self.stop_nodes()
|
||||||
self.stop_nodes()
|
# set lower ancestor limit for later
|
||||||
# set lower ancestor limit for later
|
self.start_node(0, ['-reindex', "-limitancestorcount=" + str(chainlimit)])
|
||||||
self.start_node(0, [m, "-limitancestorcount=" + str(chainlimit)])
|
self.start_node(1, ['-reindex', "-limitancestorcount=" + str(chainlimit)])
|
||||||
self.start_node(1, [m, "-limitancestorcount=" + str(chainlimit)])
|
self.start_node(2, ['-reindex', "-limitancestorcount=" + str(chainlimit)])
|
||||||
self.start_node(2, [m, "-limitancestorcount=" + str(chainlimit)])
|
# reindex will leave rpc warm up "early"; Wait for it to finish
|
||||||
if m == '-reindex':
|
self.wait_until(lambda: [block_count] * 3 == [self.nodes[i].getblockcount() for i in range(3)])
|
||||||
# reindex will leave rpc warm up "early"; Wait for it to finish
|
assert_equal(balance_nodes, [self.nodes[i].getbalance() for i in range(3)])
|
||||||
self.wait_until(lambda: [block_count] * 3 == [self.nodes[i].getblockcount() for i in range(3)])
|
|
||||||
assert_equal(balance_nodes, [self.nodes[i].getbalance() for i in range(3)])
|
|
||||||
|
|
||||||
# Exercise listsinceblock with the last two blocks
|
# Exercise listsinceblock with the last two blocks
|
||||||
coinbase_tx_1 = self.nodes[0].listsinceblock(blocks[0])
|
coinbase_tx_1 = self.nodes[0].listsinceblock(blocks[0])
|
||||||
|
|
|
@ -103,7 +103,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
# Needs rescan
|
# Needs rescan
|
||||||
self.restart_node(1, extra_args=self.extra_args[1] + ['-rescan'])
|
self.nodes[1].rescanblockchain()
|
||||||
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
|
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
|
||||||
|
|
||||||
# Try a RPC based rescan
|
# Try a RPC based rescan
|
||||||
|
|
Loading…
Add table
Reference in a new issue