Skip to content

Commit d321046

Browse files
committed
wallet: remove -salvagewallet
1 parent cdd955e commit d321046

File tree

7 files changed

+5
-38
lines changed

7 files changed

+5
-38
lines changed

src/wallet/init.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void WalletInit::AddWalletOptions() const
5454
gArgs.AddArg("-paytxfee=<amt>", strprintf("Fee (in %s/kB) to add to transactions you send (default: %s)",
5555
CURRENCY_UNIT, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
5656
gArgs.AddArg("-rescan", "Rescan the block chain for missing wallet transactions on startup", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
57-
gArgs.AddArg("-salvagewallet", "Attempt to recover private keys from a corrupt wallet on startup", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
5857
gArgs.AddArg("-spendzeroconfchange", strprintf("Spend unconfirmed change when sending transactions (default: %u)", DEFAULT_SPEND_ZEROCONF_CHANGE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
5958
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);
6059
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
8988
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
9089
}
9190

92-
if (gArgs.GetBoolArg("-salvagewallet", false)) {
93-
if (is_multiwallet) {
94-
return InitError(strprintf(Untranslated("%s is only allowed with a single wallet file"), "-salvagewallet"));
95-
}
96-
// Rewrite just private keys: rescan to find transactions
97-
if (gArgs.SoftSetBoolArg("-rescan", true)) {
98-
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
99-
}
100-
}
101-
10291
bool zapwallettxes = gArgs.GetBoolArg("-zapwallettxes", false);
10392
// -zapwallettxes implies dropping the mempool on startup
10493
if (zapwallettxes && gArgs.SoftSetBoolArg("-persistmempool", false)) {

src/wallet/load.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
3737

3838
chain.initMessage(_("Verifying wallet(s)...").translated);
3939

40-
// Parameter interaction code should have thrown an error if -salvagewallet
41-
// was enabled with more than wallet file, so the wallet_files size check
42-
// here should have no effect.
43-
bool salvage_wallet = gArgs.GetBoolArg("-salvagewallet", false) && wallet_files.size() <= 1;
44-
4540
// Keep track of each wallet absolute path to detect duplicates.
4641
std::set<fs::path> wallet_paths;
4742

@@ -55,7 +50,7 @@ bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wal
5550

5651
bilingual_str error_string;
5752
std::vector<bilingual_str> warnings;
58-
bool verify_success = CWallet::Verify(chain, location, salvage_wallet, error_string, warnings);
53+
bool verify_success = CWallet::Verify(chain, location, error_string, warnings);
5954
if (!warnings.empty()) chain.initWarning(Join(warnings, Untranslated("\n")));
6055
if (!verify_success) {
6156
chain.initError(error_string);

src/wallet/load.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class Chain;
1616
} // namespace interfaces
1717

1818
//! Responsible for reading and validating the -wallet arguments and verifying the wallet database.
19-
//! This function will perform salvage on the wallet if requested, as long as only one wallet is
20-
//! being loaded (WalletInit::ParameterInteraction() forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
2119
bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wallet_files);
2220

2321
//! Load wallet databases.

src/wallet/wallet.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void UnloadWallet(std::shared_ptr<CWallet>&& wallet)
153153
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const WalletLocation& location, bilingual_str& error, std::vector<bilingual_str>& warnings)
154154
{
155155
try {
156-
if (!CWallet::Verify(chain, location, false, error, warnings)) {
156+
if (!CWallet::Verify(chain, location, error, warnings)) {
157157
error = Untranslated("Wallet file verification failed.") + Untranslated(" ") + error;
158158
return nullptr;
159159
}
@@ -195,7 +195,7 @@ WalletCreationStatus CreateWallet(interfaces::Chain& chain, const SecureString&
195195
}
196196

197197
// Wallet::Verify will check if we're trying to create a wallet with a duplicate name.
198-
if (!CWallet::Verify(chain, location, false, error, warnings)) {
198+
if (!CWallet::Verify(chain, location, error, warnings)) {
199199
error = Untranslated("Wallet file verification failed.") + Untranslated(" ") + error;
200200
return WalletCreationStatus::CREATION_FAILED;
201201
}
@@ -3654,7 +3654,7 @@ std::vector<std::string> CWallet::GetDestValues(const std::string& prefix) const
36543654
return values;
36553655
}
36563656

3657-
bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, bool salvage_wallet, bilingual_str& error_string, std::vector<bilingual_str>& warnings)
3657+
bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, bilingual_str& error_string, std::vector<bilingual_str>& warnings)
36583658
{
36593659
// Do some checking on wallet path. It should be either a:
36603660
//
@@ -3694,15 +3694,6 @@ bool CWallet::Verify(interfaces::Chain& chain, const WalletLocation& location, b
36943694
return false;
36953695
}
36963696

3697-
if (salvage_wallet) {
3698-
// Recover readable keypairs:
3699-
CWallet dummyWallet(&chain, WalletLocation(), WalletDatabase::CreateDummy());
3700-
std::string backup_filename;
3701-
if (!WalletBatch::Recover(wallet_path, (void *)&dummyWallet, WalletBatch::RecoverKeysOnlyFilter, backup_filename)) {
3702-
return false;
3703-
}
3704-
}
3705-
37063697
return WalletBatch::VerifyDatabaseFile(wallet_path, warnings, error_string);
37073698
}
37083699

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
11371137
bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
11381138

11391139
//! Verify wallet naming and perform salvage on the wallet if required
1140-
static bool Verify(interfaces::Chain& chain, const WalletLocation& location, bool salvage_wallet, bilingual_str& error_string, std::vector<bilingual_str>& warnings);
1140+
static bool Verify(interfaces::Chain& chain, const WalletLocation& location, bilingual_str& error_string, std::vector<bilingual_str>& warnings);
11411141

11421142
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
11431143
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);

test/functional/wallet_basic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,6 @@ def run_test(self):
404404
'-reindex',
405405
'-zapwallettxes=1',
406406
'-zapwallettxes=2',
407-
# disabled until issue is fixed: https://github.com/bitcoin/bitcoin/issues/7463
408-
# '-salvagewallet',
409407
]
410408
chainlimit = 6
411409
for m in maintenance:

test/functional/wallet_multiwallet.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ def wallet_file(name):
122122
self.nodes[0].assert_start_raises_init_error(['-zapwallettxes=1', '-wallet=w1', '-wallet=w2'], "Error: -zapwallettxes is only allowed with a single wallet file")
123123
self.nodes[0].assert_start_raises_init_error(['-zapwallettxes=2', '-wallet=w1', '-wallet=w2'], "Error: -zapwallettxes is only allowed with a single wallet file")
124124

125-
self.log.info("Do not allow -salvagewallet with multiwallet")
126-
self.nodes[0].assert_start_raises_init_error(['-salvagewallet', '-wallet=w1', '-wallet=w2'], "Error: -salvagewallet is only allowed with a single wallet file")
127-
self.nodes[0].assert_start_raises_init_error(['-salvagewallet=1', '-wallet=w1', '-wallet=w2'], "Error: -salvagewallet is only allowed with a single wallet file")
128-
129125
# if wallets/ doesn't exist, datadir should be the default wallet dir
130126
wallet_dir2 = data_dir('walletdir')
131127
os.rename(wallet_dir(), wallet_dir2)

0 commit comments

Comments
 (0)