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)
3827
3827
if (fFirstRun )
3828
3828
{
3829
3829
// 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
+ }
3830
3834
walletInstance->SetMinVersion (FEATURE_NO_DEFAULT_KEY);
3831
3835
3832
3836
// generate a new master key
@@ -3843,9 +3847,9 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
3843
3847
walletInstance->SetBestChain (chainActive.GetLocator ());
3844
3848
}
3845
3849
else if (gArgs .IsArgSet (" -usehd" )) {
3846
- bool useHD = gArgs .GetBoolArg (" -usehd" , DEFAULT_USE_HD_WALLET );
3850
+ bool useHD = gArgs .GetBoolArg (" -usehd" , true );
3847
3851
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));
3849
3853
return nullptr ;
3850
3854
}
3851
3855
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;
65
65
static const bool DEFAULT_WALLET_RBF = false ;
66
66
static const bool DEFAULT_WALLETBROADCAST = true ;
67
67
static 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 ;
70
68
71
69
extern const char * DEFAULT_WALLET_DAT;
72
70
Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ def set_test_params(self):
20
20
def run_test (self ):
21
21
tmpdir = self .options .tmpdir
22
22
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
+
23
29
# Make sure we use hd, keep masterkeyid
24
30
masterkeyid = self .nodes [1 ].getwalletinfo ()['hdmasterkeyid' ]
25
31
assert_equal (len (masterkeyid ), 40 )
You can’t perform that action at this time.
0 commit comments