From a6e965538693926f410147aef9bc577920bc3c85 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 30 Sep 2021 20:43:41 +0200 Subject: [PATCH 1/2] Merge bitcoin/bitcoin#23123: Remove `-rescan` startup parameter dc3ec74d67abc85e8f724648f93efdd097e6f783 Add rescan removal release note (Samuel Dobson) bccd1d942d971e70e7a0f4f5628e1b74b3ac15e0 Remove -rescan startup parameter (Samuel Dobson) f963b0fa8cdd5223feb828c5faf6c57bc4107c8a Corrupt wallet tx shouldn't trigger rescan of all wallets (Samuel Dobson) 6c006495ef07f163d0734ec35d3cd1589a4aae9d Remove outdated dummy wallet -salvagewallet arg (Samuel Dobson) Pull request description: Remove the `-rescan` startup parameter. Rescans can be run with the `rescanblockchain` RPC. Rescans are still done on wallet-load if needed due to corruption, for example. ACKs for top commit: achow101: ACK dc3ec74d67abc85e8f724648f93efdd097e6f783 laanwj: re-ACK dc3ec74d67abc85e8f724648f93efdd097e6f783 Tree-SHA512: 608360d0e7d73737fd3ef408b01b33d97a75eebccd70c6d1b47a32fecb99b9105b520b111b225beb10611c09aa840a2b6d2b6e6e54be5d0362829e757289de5c Co-authored-by: W. J. van der Laan --- doc/release-notes-remove-rescan.md | 9 ++++++++ src/dummywallet.cpp | 2 -- src/init.cpp | 2 +- src/wallet/init.cpp | 2 -- src/wallet/rpc/backup.cpp | 4 ++-- src/wallet/rpc/wallet.cpp | 2 +- src/wallet/salvage.cpp | 2 +- src/wallet/test/wallet_tests.cpp | 4 ++-- src/wallet/wallet.cpp | 21 +++++++++++-------- src/wallet/wallet.h | 2 +- src/wallet/walletdb.cpp | 8 ++++++-- src/wallet/walletdb.h | 3 ++- src/wallet/wallettool.cpp | 4 ++++ test/functional/feature_notifications.py | 12 ++++------- test/functional/wallet_basic.py | 26 +++++++++--------------- test/functional/wallet_hd.py | 2 +- test/functional/wallet_upgradetohd.py | 8 ++------ 17 files changed, 58 insertions(+), 55 deletions(-) create mode 100644 doc/release-notes-remove-rescan.md diff --git a/doc/release-notes-remove-rescan.md b/doc/release-notes-remove-rescan.md new file mode 100644 index 000000000000..4122c1a1b5d9 --- /dev/null +++ b/doc/release-notes-remove-rescan.md @@ -0,0 +1,9 @@ +Notable changes +=============== + +Rescan startup parameter removed +-------------------------------- + +The `-rescan` startup parameter has been removed. Wallets which require +rescanning due to corruption will still be rescanned on startup. +Otherwise, please use the `rescanblockchain` RPC to trigger a rescan. diff --git a/src/dummywallet.cpp b/src/dummywallet.cpp index 14eb342d596e..24f624e6c209 100644 --- a/src/dummywallet.cpp +++ b/src/dummywallet.cpp @@ -49,8 +49,6 @@ void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const "-keypool=", "-maxapsfee=", "-maxtxfee=", - "-rescan=", - "-salvagewallet", "-signer=", "-spendzeroconfchange", "-wallet=", diff --git a/src/init.cpp b/src/init.cpp index c6f641e7e407..f63b9bd42aa7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -592,7 +592,7 @@ void SetupServerArgs(ArgsManager& argsman) -GetNumCores(), llmq::MAX_BLSCHECK_THREADS, llmq::DEFAULT_BLSCHECK_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("-pid=", 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=", 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, -addressindex, -spentindex, -rescan and -disablegovernance=false. " + argsman.AddArg("-prune=", 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, -addressindex, -spentindex and -disablegovernance=false. " "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); argsman.AddArg("-settings=", strprintf("Specify path to dynamic settings data file. Can be disabled with -nosettings. File is written at runtime and not meant to be edited by users (use %s instead for custom settings). Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME, BITCOIN_SETTINGS_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 90fef2542e9f..268eda39a9ac 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -65,8 +65,6 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const argsman.AddArg("-instantsendnotify=", "Execute command when a wallet InstantSend transaction is successfully locked. %s in cmd is replaced by TxID and %w is replaced by wallet name. %w is not currently implemented on Windows. On systems where %w is supported, it should NOT be quoted because this would break shell escaping used to invoke the command.", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); #endif argsman.AddArg("-keypool=", strprintf("Set key pool size to (default: %u). Warning: Smaller sizes may increase the risk of losing funds when restoring from an old backup, if none of the addresses in the original keypool have been used.", DEFAULT_KEYPOOL_SIZE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); - argsman.AddArg("-rescan=", "Rescan the block chain for missing wallet transactions on startup" - " (1 = start from wallet creation time, 2 = start from genesis block)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); #ifdef ENABLE_EXTERNAL_SIGNER argsman.AddArg("-signer=", "External signing tool, see doc/external-signer.md", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); #endif diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index c3892170501f..9b00bf31cab2 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -1665,7 +1665,7 @@ RPCHelpMan importmulti() "and coins using this key may not appear in the wallet. This error could be " "caused by pruning or data corruption (see dashd log for details) and could " "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))); response.push_back(std::move(result)); } @@ -1964,7 +1964,7 @@ RPCHelpMan importdescriptors() { "and coins using this desc may not appear in the wallet. This error could be " "caused by pruning or data corruption (see dashd log for details) and could " "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))); response.push_back(std::move(result)); } diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp index 63f32f37bae4..2400fa93e3a0 100644 --- a/src/wallet/rpc/wallet.cpp +++ b/src/wallet/rpc/wallet.cpp @@ -461,7 +461,7 @@ static RPCHelpMan loadwallet() return RPCHelpMan{"loadwallet", "\nLoads a wallet from a wallet file or directory." "\nNote that all wallet command-line options used when starting dashd 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."}, {"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."}, diff --git a/src/wallet/salvage.cpp b/src/wallet/salvage.cpp index d7df7f2d1876..d55c68ecdc4f 100644 --- a/src/wallet/salvage.cpp +++ b/src/wallet/salvage.cpp @@ -47,7 +47,7 @@ bool RecoverDatabaseFile(const ArgsManager& args, const fs::path& file_path, bil // Call Salvage with fAggressive=true to // get as much data as possible. // Rewrite salvaged data to fresh wallet file - // Set -rescan so any missing transactions will be + // Rescan so any missing transactions will be // found. int64_t now = GetTime(); std::string newFilename = strprintf("%s.%d.bak", filename, now); diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 777dd4b07b8c..d4e9380b172f 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -276,8 +276,8 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup) "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 " "by pruning or data corruption (see dashd log for details) and could be dealt with by " - "downloading and rescanning the relevant blocks (see -reindex and -rescan " - "options).\"}},{\"success\":true}]", + "downloading and rescanning the relevant blocks (see -reindex option and rescanblockchain " + "RPC).\"}},{\"success\":true}]", 0, oldTip->GetBlockTimeMax(), TIMESTAMP_WINDOW)); RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d12810de74bd..4d73f4e8cccd 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1932,7 +1932,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc WalletLogPrintf("Rescan started from block %s... (%s)\n", start_block.ToString(), fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks"); - 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 end_hash = tip_hash; if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash)); @@ -2439,15 +2439,12 @@ DBErrors CWallet::LoadWallet() } } - if (nLoadWalletRet != DBErrors::LOAD_OK) - return nLoadWalletRet; - /* If the CoinJoin salt is not set, try to set a new random hash as the salt */ - if (GetCoinJoinSalt().IsNull() && !SetCoinJoinSalt(GetRandHash())) { + if (nLoadWalletRet == DBErrors::LOAD_OK && GetCoinJoinSalt().IsNull() && !SetCoinJoinSalt(GetRandHash())) { return DBErrors::LOAD_FAIL; } - return DBErrors::LOAD_OK; + return nLoadWalletRet; } // Goes through all wallet transactions and checks if they are masternode collaterals, in which case these are locked @@ -3102,6 +3099,7 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri if (!walletInstance->AutoBackupWallet(fs::PathFromString(walletFile), error, warnings) && !error.original.empty()) { return nullptr; } + bool rescan_required = false; DBErrors nLoadWalletRet = walletInstance->LoadWallet(); if (nLoadWalletRet != DBErrors::LOAD_OK) { @@ -3127,6 +3125,10 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri { error = strprintf(_("Wallet needed to be rewritten: restart %s to complete"), PACKAGE_NAME); return nullptr; + } else if (nLoadWalletRet == DBErrors::RESCAN_REQUIRED) { + warnings.push_back(strprintf(_("Error reading %s! Transaction data may be missing or incorrect." + " Rescanning wallet."), walletFile)); + rescan_required = true; } else { error = strprintf(_("Error loading %s"), walletFile); @@ -3382,7 +3384,7 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri NotifyWalletLoading(context, walletInstance); - if (chain && !AttachChain(walletInstance, *chain, error, warnings)) { + if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) { walletInstance->m_chain_notifications_handler.reset(); // Reset this pointer so that the wallet will actually be unloaded return nullptr; } @@ -3407,7 +3409,7 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri return walletInstance; } -bool CWallet::AttachChain(const std::shared_ptr& walletInstance, interfaces::Chain& chain, bilingual_str& error, std::vector& warnings) +bool CWallet::AttachChain(const std::shared_ptr& walletInstance, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector& warnings) { LOCK(walletInstance->cs_wallet); // allow setting the chain if it hasn't been set already but prevent changing it @@ -3441,8 +3443,9 @@ bool CWallet::AttachChain(const std::shared_ptr& walletInstance, interf walletInstance->m_attaching_chain = true; //ignores chainStateFlushed notifications walletInstance->m_chain_notifications_handler = walletInstance->chain().handleNotifications(walletInstance); + // If rescan_required = true, rescan_height remains equal to 0 int rescan_height = 0; - if (!gArgs.GetBoolArg("-rescan", false)) + if (!rescan_required) { WalletBatch batch(walletInstance->GetDatabase()); CBlockLocator locator; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 7e15a2fd9585..564f3d2559e3 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -441,7 +441,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati * block locator and m_last_block_processed, and registering for * notifications about new blocks and transactions. */ - static bool AttachChain(const std::shared_ptr& wallet, interfaces::Chain& chain, bilingual_str& error, std::vector& warnings); + static bool AttachChain(const std::shared_ptr& wallet, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector& warnings); public: /** diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index e763ba0a0928..ca0a404c80c0 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -813,6 +813,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) { CWalletScanState wss; bool fNoncriticalErrors = false; + bool rescan_required = false; DBErrors result = DBErrors::LOAD_OK; LOCK(pwallet->cs_wallet); @@ -886,7 +887,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) fNoncriticalErrors = true; // ... but do warn the user there is something wrong. if (strType == DBKeys::TX) // Rescan if there is a bad transaction record: - gArgs.SoftSetBoolArg("-rescan", true); + rescan_required = true; } } if (!strErr.empty()) @@ -950,8 +951,11 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) } } - if (fNoncriticalErrors && result == DBErrors::LOAD_OK) + if (rescan_required && result == DBErrors::LOAD_OK) { + result = DBErrors::RESCAN_REQUIRED; + } else if (fNoncriticalErrors && result == DBErrors::LOAD_OK) { result = DBErrors::NONCRITICAL_ERROR; + } // Any wallet corruption at all: skip any rewriting or // upgrading, we don't want to make it worse. diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index e24a45d2ab24..2524dc9ee5eb 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -56,7 +56,8 @@ enum class DBErrors TOO_NEW, EXTERNAL_SIGNER_SUPPORT_REQUIRED, LOAD_FAIL, - NEED_REWRITE + NEED_REWRITE, + RESCAN_REQUIRED }; namespace DBKeys { diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index e6235f31fd69..aad7d39c24ab 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -92,6 +92,10 @@ static std::shared_ptr MakeWallet(const std::string& name, const fs::pa } else if (load_wallet_ret == DBErrors::NEED_REWRITE) { tfm::format(std::cerr, "Wallet needed to be rewritten: restart %s to complete", PACKAGE_NAME); return nullptr; + } else if (load_wallet_ret == DBErrors::RESCAN_REQUIRED) { + tfm::format(std::cerr, "Error reading %s! Some transaction data might be missing or" + " incorrect. Wallet requires a rescan.", + name); } else { tfm::format(std::cerr, "Error loading %s", name); return nullptr; diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py index c0fd38ddcfad..a77ae3dbb0ff 100755 --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -11,7 +11,6 @@ from test_framework.test_framework import DashTestFramework from test_framework.util import ( assert_equal, - force_finish_mnsync, ) # Linux allow all characters other than \x00 @@ -56,7 +55,6 @@ def setup_network(self): f"-shutdownnotify=echo > {self.shutdownnotify_file}", f"-chainlocknotify=echo > {os.path.join(self.chainlocknotify_dir, '%s')}", ], [ - "-rescan", f"-walletnotify=echo %h_%b > {os.path.join(self.walletnotify_dir, notify_outputname('%w', '%s'))}", f"-instantsendnotify=echo > {os.path.join(self.instantsendnotify_dir, notify_outputname('%w', '%s'))}", ], @@ -89,17 +87,15 @@ def run_test(self): # 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))) - self.stop_node(1) self.expect_wallet_notify(tx_details) self.log.info("test -walletnotify after rescan") - # restart node to rescan to force wallet notifications - self.start_node(1) - force_finish_mnsync(self.nodes[1]) - self.connect_nodes(0, 1) - + # rescan to force wallet notifications + self.nodes[1].rescanblockchain() 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 tx_details = list(map(lambda t: (t['txid'], t['blockheight'], t['blockhash']), self.nodes[1].listtransactions("*", block_count))) self.expect_wallet_notify(tx_details) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 4b8bc4a328e9..de4608d8c79c 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -620,23 +620,17 @@ def run_test(self): assert label in self.nodes[0].listlabels() self.nodes[0].rpc.ensure_ascii = True # restore to default - # maintenance tests - maintenance = [ - '-rescan', - '-reindex', - ] + # -reindex tests chainlimit = 6 - for m in maintenance: - self.log.info("Test " + m) - self.stop_nodes() - # set lower ancestor limit for later - self.start_node(0, [m, "-walletrejectlongchains=0", "-limitancestorcount=" + str(chainlimit)]) - self.start_node(1, [m, "-limitancestorcount=" + str(chainlimit)]) - self.start_node(2, [m, "-limitancestorcount=" + str(chainlimit)]) - if m == '-reindex': - # reindex will leave rpc warm up "early"; Wait for it to finish - 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)]) + self.log.info("Test -reindex") + self.stop_nodes() + # set lower ancestor limit for later + self.start_node(0, ["-reindex", "-walletrejectlongchains=0", "-limitancestorcount=" + str(chainlimit)]) + self.start_node(1, ["-reindex", "-limitancestorcount=" + str(chainlimit)]) + self.start_node(2, ["-reindex", "-limitancestorcount=" + str(chainlimit)]) + # reindex will leave rpc warm up "early"; Wait for it to finish + 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 coinbase_tx_1 = self.nodes[0].listsinceblock(blocks[0]) diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index 67794d69a2ac..aa830e4d009a 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -109,7 +109,7 @@ def run_test(self): self.sync_all() # 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) # Try a RPC based rescan diff --git a/test/functional/wallet_upgradetohd.py b/test/functional/wallet_upgradetohd.py index 5d65829de5f9..2ccf9cfd826b 100755 --- a/test/functional/wallet_upgradetohd.py +++ b/test/functional/wallet_upgradetohd.py @@ -188,9 +188,7 @@ def run_test(self): self.log.info("Same mnemonic, same mnemonic passphrase, encrypt wallet on upgrade, should recover all coins after rescan") walletpass = "111pass222" assert node.upgradetohd(mnemonic[0], "", walletpass) - node.stop() - node.wait_until_stopped() - self.start_node(0, extra_args=['-rescan']) + self.nodes[0].rescanblockchain() assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.", node.dumphdinfo) node.walletpassphrase(walletpass, 100) assert_equal(mnemonic, get_mnemonic(node)) @@ -211,9 +209,7 @@ def run_test(self): # Null characters are allowed in wallet passphrases since v23 walletpass = "111\0pass222" node.encryptwallet(walletpass) - node.stop() - node.wait_until_stopped() - self.start_node(0, extra_args=['-rescan']) + self.nodes[0].rescanblockchain() assert_raises_rpc_error(-13, "Error: Wallet encrypted but passphrase not supplied to RPC.", node.upgradetohd, mnemonic[0]) assert_raises_rpc_error(-14, "Error: The wallet passphrase entered was incorrect", node.upgradetohd, mnemonic[0], "", "111") assert node.upgradetohd(mnemonic[0], "", walletpass) From 2970303a87b4432109e076a19f060b7464c3309b Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 1 Oct 2021 10:39:47 +0800 Subject: [PATCH 2/2] Merge bitcoin/bitcoin#23147: refactor: rename DBErrors::RESCAN_REQUIRED to NEED_RESCAN 8615507a4e510bc797b01c4bbe45dc1f91e0bfa0 scripted-diff: rename DBErrors::RESCAN_REQUIRED to NEED_RESCAN (Samuel Dobson) Pull request description: Suggested here as a trivial follow-up: https://github.com/bitcoin/bitcoin/pull/23123#discussion_r719709924 Makes RESCAN_REQUIRED consistent with NEED_REWRITE ACKs for top commit: achow101: ACK 8615507a4e510bc797b01c4bbe45dc1f91e0bfa0 jonatack: ACK 8615507a4e510bc797b01c4bbe45dc1f91e0bfa0 Tree-SHA512: 82d057c45e192cd6dd8a47675b52699e6cbc82272609a971e6e5d6796aad14a941a70e40d3913dbb611f79c8eadff8030c60ea6f203f2edc3720c0e78c166b97 Co-authored-by: fanquake --- src/wallet/wallet.cpp | 2 +- src/wallet/walletdb.cpp | 2 +- src/wallet/walletdb.h | 2 +- src/wallet/wallettool.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4d73f4e8cccd..bda967c449b5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3125,7 +3125,7 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri { error = strprintf(_("Wallet needed to be rewritten: restart %s to complete"), PACKAGE_NAME); return nullptr; - } else if (nLoadWalletRet == DBErrors::RESCAN_REQUIRED) { + } else if (nLoadWalletRet == DBErrors::NEED_RESCAN) { warnings.push_back(strprintf(_("Error reading %s! Transaction data may be missing or incorrect." " Rescanning wallet."), walletFile)); rescan_required = true; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index ca0a404c80c0..dd7366ca30b7 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -952,7 +952,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) } if (rescan_required && result == DBErrors::LOAD_OK) { - result = DBErrors::RESCAN_REQUIRED; + result = DBErrors::NEED_RESCAN; } else if (fNoncriticalErrors && result == DBErrors::LOAD_OK) { result = DBErrors::NONCRITICAL_ERROR; } diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 2524dc9ee5eb..eb5ce4b37d9a 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -57,7 +57,7 @@ enum class DBErrors EXTERNAL_SIGNER_SUPPORT_REQUIRED, LOAD_FAIL, NEED_REWRITE, - RESCAN_REQUIRED + NEED_RESCAN }; namespace DBKeys { diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index aad7d39c24ab..726a71d2bbf8 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -92,7 +92,7 @@ static std::shared_ptr MakeWallet(const std::string& name, const fs::pa } else if (load_wallet_ret == DBErrors::NEED_REWRITE) { tfm::format(std::cerr, "Wallet needed to be rewritten: restart %s to complete", PACKAGE_NAME); return nullptr; - } else if (load_wallet_ret == DBErrors::RESCAN_REQUIRED) { + } else if (load_wallet_ret == DBErrors::NEED_RESCAN) { tfm::format(std::cerr, "Error reading %s! Some transaction data might be missing or" " incorrect. Wallet requires a rescan.", name);