Skip to content

Commit c22a53c

Browse files
committed
Merge #11250: Bump wallet version to 159900 and remove the usehd option
713a920 Remove usehd option and warn when it is used (Andrew Chow) d4c18f7 Bump wallet version number to 159900 (Andrew Chow) Pull request description: Bump the wallet version number to 159900 so that new wallets made without a default key will no longer work on previous versions at all. Also remove the `usehd` option to avoid weird interaction with wallet version numbers and HD-ness of wallets. Tree-SHA512: dd7965505bfad6a926c79afd423236f509229a398a8398076f8d57d90a5974243f9459a61225c4daee560c796f427445c9e55a3ad528a3a97a9123ca6a1269ab
2 parents 791a0e6 + 713a920 commit c22a53c

File tree

6 files changed

+12
-22
lines changed

6 files changed

+12
-22
lines changed

src/wallet/init.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ std::string GetWalletHelpString(bool showDebug)
3030
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup"));
3131
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
3232
strUsage += HelpMessageOpt("-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));
33-
strUsage += HelpMessageOpt("-usehd", _("Use hierarchical deterministic key generation (HD) after BIP32. Only has effect during wallet creation/first start") + " " + strprintf(_("(default: %u)"), DEFAULT_USE_HD_WALLET));
3433
strUsage += HelpMessageOpt("-walletrbf", strprintf(_("Send transactions with full-RBF opt-in enabled (default: %u)"), DEFAULT_WALLET_RBF));
3534
strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup"));
3635
strUsage += HelpMessageOpt("-wallet=<file>", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT));

src/wallet/wallet.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3826,17 +3826,13 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
38263826

38273827
if (fFirstRun)
38283828
{
3829-
// Create new keyUser and set as default key
3830-
if (gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsHDEnabled()) {
3829+
// ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
3830+
walletInstance->SetMinVersion(FEATURE_NO_DEFAULT_KEY);
38313831

3832-
// ensure this wallet.dat can only be opened by clients supporting HD with chain split
3833-
walletInstance->SetMinVersion(FEATURE_HD_SPLIT);
3834-
3835-
// generate a new master key
3836-
CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey();
3837-
if (!walletInstance->SetHDMasterKey(masterPubKey))
3838-
throw std::runtime_error(std::string(__func__) + ": Storing master key failed");
3839-
}
3832+
// generate a new master key
3833+
CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey();
3834+
if (!walletInstance->SetHDMasterKey(masterPubKey))
3835+
throw std::runtime_error(std::string(__func__) + ": Storing master key failed");
38403836

38413837
// Top up the keypool
38423838
if (!walletInstance->TopUpKeyPool()) {
@@ -3849,7 +3845,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
38493845
else if (gArgs.IsArgSet("-usehd")) {
38503846
bool useHD = gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
38513847
if (walletInstance->IsHDEnabled() && !useHD) {
3852-
InitError(strprintf(_("Error loading %s: You can't disable HD on an already existing HD wallet"), walletFile));
3848+
InitError(strprintf(_("Error loading %s: You can't disable HD on an already existing HD wallet or create new non-HD wallets."), walletFile));
38533849
return nullptr;
38543850
}
38553851
if (!walletInstance->IsHDEnabled() && useHD) {

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ enum WalletFeature
9696

9797
FEATURE_HD_SPLIT = 139900, // Wallet with HD chain split (change outputs will use m/0'/1'/k)
9898

99+
FEATURE_NO_DEFAULT_KEY = 159900, // Wallet without a default key written
100+
99101
FEATURE_LATEST = FEATURE_COMPRPUBKEY // HD is optional, use FEATURE_COMPRPUBKEY as latest version
100102
};
101103

test/functional/keypool-topup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class KeypoolRestoreTest(BitcoinTestFramework):
2323
def set_test_params(self):
2424
self.setup_clean_chain = True
2525
self.num_nodes = 2
26-
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=100', '-keypoolmin=20']]
26+
self.extra_args = [[], ['-keypool=100', '-keypoolmin=20']]
2727

2828
def run_test(self):
2929
self.tmpdir = self.options.tmpdir

test/functional/wallet-hd.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ class WalletHDTest(BitcoinTestFramework):
1515
def set_test_params(self):
1616
self.setup_clean_chain = True
1717
self.num_nodes = 2
18-
self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=0']]
18+
self.extra_args = [[], ['-keypool=0']]
1919

2020
def run_test (self):
2121
tmpdir = self.options.tmpdir
2222

23-
# Make sure can't switch off usehd after wallet creation
24-
self.stop_node(1)
25-
self.assert_start_raises_init_error(1, ['-usehd=0'], 'already existing HD wallet')
26-
self.start_node(1)
27-
connect_nodes_bi(self.nodes, 0, 1)
28-
2923
# Make sure we use hd, keep masterkeyid
3024
masterkeyid = self.nodes[1].getwalletinfo()['hdmasterkeyid']
3125
assert_equal(len(masterkeyid), 40)

test/functional/wallet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ class WalletTest(BitcoinTestFramework):
1010
def set_test_params(self):
1111
self.num_nodes = 4
1212
self.setup_clean_chain = True
13-
self.extra_args = [['-usehd={:d}'.format(i%2==0)] for i in range(4)]
1413

1514
def setup_network(self):
16-
self.add_nodes(4, self.extra_args)
15+
self.add_nodes(4)
1716
self.start_node(0)
1817
self.start_node(1)
1918
self.start_node(2)

0 commit comments

Comments
 (0)