diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -14,6 +14,7 @@ - The `createrawtransaction` RPC will now accept an array or dictionary (kept for compatibility) for the `outputs` parameter. This means the order of transaction outputs can be specified by the client. - The new RPC `testmempoolaccept` can be used to test acceptance of a transaction to the mempool without adding it. - An `initialblockdownload` boolean has been added to the `getblockchaininfo` RPC to indicate whether the node is currently in IBD or not. + - The '-usehd' option has been removed. It is no longer possible to create a non HD wallet. Transaction index changes ------------------------- diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -85,12 +85,6 @@ "transactions (default: %d)"), DEFAULT_SPEND_ZEROCONF_CHANGE), false, OptionsCategory::WALLET); - gArgs.AddArg( - "-usehd", - _("Use hierarchical deterministic key generation (HD) after BIP32. " - "Only has effect during wallet creation/first start") + - " " + strprintf(_("(default: %d)"), DEFAULT_USE_HD_WALLET), - false, OptionsCategory::WALLET); gArgs.AddArg("-upgradewallet", _("Upgrade wallet to latest format on startup"), false, OptionsCategory::WALLET); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -91,6 +91,9 @@ // Wallet with HD chain split (change outputs will use m/0'/1'/k) FEATURE_HD_SPLIT = 160300, + // Wallet without a default key written + FEATURE_NO_DEFAULT_KEY = 190700, + // HD is optional, use FEATURE_COMPRPUBKEY as latest version FEATURE_LATEST = FEATURE_COMPRPUBKEY, }; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4275,20 +4275,15 @@ } if (fFirstRun) { - // Create new keyUser and set as default key. - if (gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && - !walletInstance->IsHDEnabled()) { - - // Ensure this wallet.dat can only be opened by clients supporting - // HD with chain split. - walletInstance->SetMinVersion(FEATURE_HD_SPLIT); - - // Generate a new master key. - CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey(); - if (!walletInstance->SetHDMasterKey(masterPubKey)) { - throw std::runtime_error(std::string(__func__) + - ": Storing master key failed"); - } + // Ensure this wallet.dat can only be opened by clients supporting + // HD with chain split and expects no default key. + walletInstance->SetMinVersion(FEATURE_NO_DEFAULT_KEY); + + // Generate a new master key. + CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey(); + if (!walletInstance->SetHDMasterKey(masterPubKey)) { + throw std::runtime_error(std::string(__func__) + + ": Storing master key failed"); } // Top up the keypool @@ -4310,7 +4305,8 @@ if (!walletInstance->IsHDEnabled() && useHD) { InitError(strprintf(_("Error loading %s: You can't enable HD on an " - "already existing non-HD wallet"), + "already existing non-HD wallet or create " + "new non-HD wallets."), walletFile)); return nullptr; } diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -24,11 +24,9 @@ def set_test_params(self): self.num_nodes = 4 self.setup_clean_chain = True - self.extra_args = [ - ['-usehd={:d}'.format(i % 2 == 0)] for i in range(4)] def setup_network(self): - self.add_nodes(4, self.extra_args) + self.add_nodes(4) self.start_node(0) self.start_node(1) self.start_node(2) diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -15,16 +15,9 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 - self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=0']] + self.extra_args = [[], ['-keypool=0']] def run_test(self): - # Make sure can't switch off usehd after wallet creation - self.stop_node(1) - self.assert_start_raises_init_error( - 1, ['-usehd=0'], 'already existing HD wallet') - self.start_node(1) - connect_nodes_bi(self.nodes[0], self.nodes[1]) - # Make sure we use hd, keep masterkeyid masterkeyid = self.nodes[1].getwalletinfo()['hdmasterkeyid'] assert_equal(len(masterkeyid), 40) diff --git a/test/functional/wallet_keypool_topup.py b/test/functional/wallet_keypool_topup.py --- a/test/functional/wallet_keypool_topup.py +++ b/test/functional/wallet_keypool_topup.py @@ -25,8 +25,7 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 2 - self.extra_args = [['-usehd=0'], - ['-usehd=1', '-keypool=100', '-keypoolmin=20']] + self.extra_args = [[], ['-keypool=100', '-keypoolmin=20']] def run_test(self): wallet_path = os.path.join( diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -41,6 +41,7 @@ '-rpcssl', '-socks', '-tor', + '-usehd', '-whitelistalwaysrelay']) # list false positive unknows arguments