File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3827,6 +3827,10 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
38273827 if (fFirstRun )
38283828 {
38293829 // ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
3830+ if (!gArgs .GetBoolArg (" -usehd" , true )) {
3831+ InitError (strprintf (_ (" Error creating %s: You can't create non-HD wallets with this version." ), walletFile));
3832+ return nullptr ;
3833+ }
38303834 walletInstance->SetMinVersion (FEATURE_NO_DEFAULT_KEY);
38313835
38323836 // generate a new master key
@@ -3843,9 +3847,9 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
38433847 walletInstance->SetBestChain (chainActive.GetLocator ());
38443848 }
38453849 else if (gArgs .IsArgSet (" -usehd" )) {
3846- bool useHD = gArgs .GetBoolArg (" -usehd" , DEFAULT_USE_HD_WALLET );
3850+ bool useHD = gArgs .GetBoolArg (" -usehd" , true );
38473851 if (walletInstance->IsHDEnabled () && !useHD) {
3848- InitError (strprintf (_ (" Error loading %s: You can't disable HD on an already existing HD wallet or create new non-HD wallets. " ), walletFile));
3852+ InitError (strprintf (_ (" Error loading %s: You can't disable HD on an already existing HD wallet" ), walletFile));
38493853 return nullptr ;
38503854 }
38513855 if (!walletInstance->IsHDEnabled () && useHD) {
Original file line number Diff line number Diff line change @@ -65,8 +65,6 @@ static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
6565static const bool DEFAULT_WALLET_RBF = false ;
6666static const bool DEFAULT_WALLETBROADCAST = true ;
6767static const bool DEFAULT_DISABLE_WALLET = false ;
68- // ! if set, all keys will be derived by using BIP32
69- static const bool DEFAULT_USE_HD_WALLET = true ;
7068
7169extern const char * DEFAULT_WALLET_DAT;
7270
Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ def set_test_params(self):
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+
2329 # Make sure we use hd, keep masterkeyid
2430 masterkeyid = self .nodes [1 ].getwalletinfo ()['hdmasterkeyid' ]
2531 assert_equal (len (masterkeyid ), 40 )
You can’t perform that action at this time.
0 commit comments