mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Remove -upgradewallet startup option
This commit is contained in:
parent
92263cce5b
commit
0d32d66148
4 changed files with 3 additions and 33 deletions
|
@ -57,7 +57,6 @@ void WalletInit::AddWalletOptions() const
|
||||||
gArgs.AddArg("-salvagewallet", "Attempt to recover private keys from a corrupt wallet 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("-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("-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("-upgradewallet", "Upgrade wallet to latest format on startup", 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);
|
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);
|
||||||
gArgs.AddArg("-walletbroadcast", strprintf("Make the wallet broadcast transactions (default: %u)", DEFAULT_WALLETBROADCAST), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
gArgs.AddArg("-walletbroadcast", strprintf("Make the wallet broadcast transactions (default: %u)", DEFAULT_WALLETBROADCAST), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
gArgs.AddArg("-walletdir=<dir>", "Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::WALLET);
|
gArgs.AddArg("-walletdir=<dir>", "Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::WALLET);
|
||||||
|
@ -116,12 +115,6 @@ bool WalletInit::ParameterInteraction() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_multiwallet) {
|
|
||||||
if (gArgs.GetBoolArg("-upgradewallet", false)) {
|
|
||||||
return InitError(strprintf("%s is only allowed with a single wallet file", "-upgradewallet"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gArgs.GetBoolArg("-sysperms", false))
|
if (gArgs.GetBoolArg("-sysperms", false))
|
||||||
return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
|
return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
|
||||||
|
|
||||||
|
|
|
@ -2586,7 +2586,7 @@ static UniValue loadwallet(const JSONRPCRequest& request)
|
||||||
RPCHelpMan{"loadwallet",
|
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 -zapwallettxes, upgradewallet, rescan, etc).\n",
|
"\napplied to the new wallet (eg -zapwallettxes, rescan, etc).\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."},
|
||||||
},
|
},
|
||||||
|
@ -4021,7 +4021,7 @@ UniValue sethdseed(const JSONRPCRequest& request)
|
||||||
|
|
||||||
// Do not do anything to non-HD wallets
|
// Do not do anything to non-HD wallets
|
||||||
if (!pwallet->CanSupportFeature(FEATURE_HD)) {
|
if (!pwallet->CanSupportFeature(FEATURE_HD)) {
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot set a HD seed on a non-HD wallet. Start with -upgradewallet in order to upgrade a non-HD wallet to HD");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot set a HD seed on a non-HD wallet. Use the upgradewallet RPC in order to upgrade a non-HD wallet to HD");
|
||||||
}
|
}
|
||||||
|
|
||||||
EnsureWalletIsUnlocked(pwallet);
|
EnsureWalletIsUnlocked(pwallet);
|
||||||
|
|
|
@ -3830,12 +3830,6 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gArgs.GetBoolArg("-upgradewallet", false)) {
|
|
||||||
if (!UpgradeWallet(gArgs.GetBoolArg("-upgradewallet", 0), error, warnings)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fFirstRun)
|
if (fFirstRun)
|
||||||
{
|
{
|
||||||
// ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
|
// ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
|
||||||
|
@ -4121,7 +4115,7 @@ bool CWallet::UpgradeWallet(int version, std::string& error, std::vector<std::st
|
||||||
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
|
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
|
||||||
int max_version = GetVersion();
|
int max_version = GetVersion();
|
||||||
if (!CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
|
if (!CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
|
||||||
error = _("Cannot upgrade a non HD split wallet without upgrading to support pre split keypool. Please use -upgradewallet=169900 or -upgradewallet with no version specified.").translated;
|
error = _("Cannot upgrade a non HD split wallet without upgrading to support pre split keypool. Please use version 169900 or no version specified.").translated;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,10 +125,6 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||||
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', '-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")
|
self.nodes[0].assert_start_raises_init_error(['-salvagewallet=1', '-wallet=w1', '-wallet=w2'], "Error: -salvagewallet is only allowed with a single wallet file")
|
||||||
|
|
||||||
self.log.info("Do not allow -upgradewallet with multiwallet")
|
|
||||||
self.nodes[0].assert_start_raises_init_error(['-upgradewallet', '-wallet=w1', '-wallet=w2'], "Error: -upgradewallet is only allowed with a single wallet file")
|
|
||||||
self.nodes[0].assert_start_raises_init_error(['-upgradewallet=1', '-wallet=w1', '-wallet=w2'], "Error: -upgradewallet is only allowed with a single wallet file")
|
|
||||||
|
|
||||||
# if wallets/ doesn't exist, datadir should be the default wallet dir
|
# if wallets/ doesn't exist, datadir should be the default wallet dir
|
||||||
wallet_dir2 = data_dir('walletdir')
|
wallet_dir2 = data_dir('walletdir')
|
||||||
os.rename(wallet_dir(), wallet_dir2)
|
os.rename(wallet_dir(), wallet_dir2)
|
||||||
|
@ -332,18 +328,5 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||||
self.nodes[0].unloadwallet(wallet)
|
self.nodes[0].unloadwallet(wallet)
|
||||||
self.nodes[1].loadwallet(wallet)
|
self.nodes[1].loadwallet(wallet)
|
||||||
|
|
||||||
# Fail to load if wallet is downgraded
|
|
||||||
shutil.copytree(os.path.join(self.options.data_wallets_dir, 'high_minversion'), wallet_dir('high_minversion'))
|
|
||||||
self.restart_node(0, extra_args=['-upgradewallet={}'.format(FEATURE_LATEST)])
|
|
||||||
assert {'name': 'high_minversion'} in self.nodes[0].listwalletdir()['wallets']
|
|
||||||
self.log.info("Fail -upgradewallet that results in downgrade")
|
|
||||||
assert_raises_rpc_error(
|
|
||||||
-4,
|
|
||||||
'Wallet loading failed: Error loading {}: Wallet requires newer version of {}'.format(
|
|
||||||
wallet_dir('high_minversion', 'wallet.dat'), self.config['environment']['PACKAGE_NAME']),
|
|
||||||
lambda: self.nodes[0].loadwallet(filename='high_minversion'),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
MultiWalletTest().main()
|
MultiWalletTest().main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue