mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
wallet: remove -salvagewallet
This commit is contained in:
parent
cdd955e580
commit
d321046f4b
7 changed files with 5 additions and 38 deletions
|
@ -54,7 +54,6 @@ void WalletInit::AddWalletOptions() const
|
|||
gArgs.AddArg("-paytxfee=<amt>", strprintf("Fee (in %s/kB) to add to transactions you send (default: %s)",
|
||||
CURRENCY_UNIT, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-rescan", "Rescan the block chain for missing wallet transactions on startup", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-salvagewallet", "Attempt to recover private keys from a corrupt wallet on startup", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-spendzeroconfchange", strprintf("Spend unconfirmed change when sending transactions (default: %u)", DEFAULT_SPEND_ZEROCONF_CHANGE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-txconfirmtarget=<n>", strprintf("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)", DEFAULT_TX_CONFIRM_TARGET), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-wallet=<path>", "Specify wallet database path. Can be specified multiple times to load multiple wallets. Path is interpreted relative to <walletdir> if it is not absolute, and will be created if it does not exist (as a directory containing a wallet.dat file and log files). For backwards compatibility this will also accept names of existing data files in <walletdir>.)", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::WALLET);
|
||||
|
@ -89,16 +88,6 @@ bool WalletInit::ParameterInteraction() const
|
|||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
|
||||
}
|
||||
|
||||
if (gArgs.GetBoolArg("-salvagewallet", false)) {
|
||||
if (is_multiwallet) {
|
||||
return InitError(strprintf(Untranslated("%s is only allowed with a single wallet file"), "-salvagewallet"));
|
||||
}
|
||||
// Rewrite just private keys: rescan to find transactions
|
||||
if (gArgs.SoftSetBoolArg("-rescan", true)) {
|
||||
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
bool zapwallettxes = gArgs.GetBoolArg("-zapwallettxes", false);
|
||||
// -zapwallettxes implies dropping the mempool on startup
|
||||
if (zapwallettxes && gArgs.SoftSetBoolArg("-persistmempool", false)) {
|
||||
|
|
|
@ -37,11 +37,6 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
|
|||
|
||||
chain.initMessage(_("Verifying wallet(s)...").translated);
|
||||
|
||||
// Parameter interaction code should have thrown an error if -salvagewallet
|
||||
// was enabled with more than wallet file, so the wallet_files size check
|
||||
// here should have no effect.
|
||||
bool salvage_wallet = gArgs.GetBoolArg("-salvagewallet", false) && wallet_files.size() <= 1;
|
||||
|
||||
// Keep track of each wallet absolute path to detect duplicates.
|
||||
std::set<fs::path> wallet_paths;
|
||||
|
||||
|
@ -55,7 +50,7 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
|
|||
|
||||
bilingual_str error_string;
|
||||
std::vector<bilingual_str> warnings;
|
||||
bool verify_success = CWallet::Verify(chain, location, salvage_wallet, error_string, warnings);
|
||||
bool verify_success = CWallet::Verify(chain, location, error_string, warnings);
|
||||
if (!warnings.empty()) chain.initWarning(Join(warnings, Untranslated("\n")));
|
||||
if (!verify_success) {
|
||||
chain.initError(error_string);
|
||||
|
|
|
@ -16,8 +16,6 @@ class Chain;
|
|||
} // namespace interfaces
|
||||
|
||||
//! Responsible for reading and validating the -wallet arguments and verifying the wallet database.
|
||||
//! This function will perform salvage on the wallet if requested, as long as only one wallet is
|
||||
//! being loaded (WalletInit::ParameterInteraction() forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
|
||||
bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wallet_files);
|
||||
|
||||
//! Load wallet databases.
|
||||
|
|
|
@ -153,7 +153,7 @@ void UnloadWallet(std::shared_ptr<CWallet>&& wallet)
|
|||
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const WalletLocation& location, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
try {
|
||||
if (!CWallet::Verify(chain, location, false, error, warnings)) {
|
||||
if (!CWallet::Verify(chain, location, error, warnings)) {
|
||||
error = Untranslated("Wallet file verification failed.") + Untranslated(" ") + error;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ WalletCreationStatus CreateWallet(interfaces::Chain& chain, const SecureString&
|
|||
}
|
||||
|
||||
// Wallet::Verify will check if we're trying to create a wallet with a duplicate name.
|
||||
if (!CWallet::Verify(chain, location, false, error, warnings)) {
|
||||
if (!CWallet::Verify(chain, location, error, warnings)) {
|
||||
error = Untranslated("Wallet file verification failed.") + Untranslated(" ") + error;
|
||||
return WalletCreationStatus::CREATION_FAILED;
|
||||
}
|
||||
|
@ -3654,7 +3654,7 @@ std::vector<std::string> CWallet::GetDestValues(const std::string& prefix) const
|
|||
return values;
|
||||
}
|
||||
|
||||
bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, bool salvage_wallet, bilingual_str& error_string, std::vector<bilingual_str>& warnings)
|
||||
bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, bilingual_str& error_string, std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
// Do some checking on wallet path. It should be either a:
|
||||
//
|
||||
|
@ -3694,15 +3694,6 @@ bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, b
|
|||
return false;
|
||||
}
|
||||
|
||||
if (salvage_wallet) {
|
||||
// Recover readable keypairs:
|
||||
CWallet dummyWallet(&chain, WalletLocation(), WalletDatabase::CreateDummy());
|
||||
std::string backup_filename;
|
||||
if (!WalletBatch::Recover(wallet_path, (void *)&dummyWallet, WalletBatch::RecoverKeysOnlyFilter, backup_filename)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return WalletBatch::VerifyDatabaseFile(wallet_path, warnings, error_string);
|
||||
}
|
||||
|
||||
|
|
|
@ -1137,7 +1137,7 @@ public:
|
|||
bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
|
||||
|
||||
//! Verify wallet naming and perform salvage on the wallet if required
|
||||
static bool Verify(interfaces::Chain& chain, const WalletLocation& location, bool salvage_wallet, bilingual_str& error_string, std::vector<bilingual_str>& warnings);
|
||||
static bool Verify(interfaces::Chain& chain, const WalletLocation& location, bilingual_str& error_string, std::vector<bilingual_str>& warnings);
|
||||
|
||||
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
|
||||
static std::shared_ptr<CWallet> CreateWalletFromFile(interfaces::Chain& chain, const WalletLocation& location, bilingual_str& error, std::vector<bilingual_str>& warnings, uint64_t wallet_creation_flags = 0);
|
||||
|
|
|
@ -404,8 +404,6 @@ class WalletTest(BitcoinTestFramework):
|
|||
'-reindex',
|
||||
'-zapwallettxes=1',
|
||||
'-zapwallettxes=2',
|
||||
# disabled until issue is fixed: https://github.com/bitcoin/bitcoin/issues/7463
|
||||
# '-salvagewallet',
|
||||
]
|
||||
chainlimit = 6
|
||||
for m in maintenance:
|
||||
|
|
|
@ -122,10 +122,6 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||
self.nodes[0].assert_start_raises_init_error(['-zapwallettxes=1', '-wallet=w1', '-wallet=w2'], "Error: -zapwallettxes is only allowed with a single wallet file")
|
||||
self.nodes[0].assert_start_raises_init_error(['-zapwallettxes=2', '-wallet=w1', '-wallet=w2'], "Error: -zapwallettxes is only allowed with a single wallet file")
|
||||
|
||||
self.log.info("Do not allow -salvagewallet with multiwallet")
|
||||
self.nodes[0].assert_start_raises_init_error(['-salvagewallet', '-wallet=w1', '-wallet=w2'], "Error: -salvagewallet is only allowed with a single wallet file")
|
||||
self.nodes[0].assert_start_raises_init_error(['-salvagewallet=1', '-wallet=w1', '-wallet=w2'], "Error: -salvagewallet is only allowed with a single wallet file")
|
||||
|
||||
# if wallets/ doesn't exist, datadir should be the default wallet dir
|
||||
wallet_dir2 = data_dir('walletdir')
|
||||
os.rename(wallet_dir(), wallet_dir2)
|
||||
|
|
Loading…
Reference in a new issue