On current master a fresh wallet created with -usehd=0 is silently created as HD wallet.
An error should be displayed on the first run.
Also, this restores a test that was removed in c22a53c
Fixes: #11313
On current master a fresh wallet created with -usehd=0 is silently created as HD wallet.
An error should be displayed on the first run.
Also, this restores a test that was removed in c22a53c
Fixes: #11313
3846 | @@ -3843,9 +3847,9 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
3847 | walletInstance->SetBestChain(chainActive.GetLocator());
3848 | }
3849 | else if (gArgs.IsArgSet("-usehd")) {
Instead of moving the code block up, couldn't this just be made an if instead of else if? If we want to show this error before doing any of the wallet creating stuff, this entire check could just be moved to before the first run block.
Yes, the else can be removed for better clarity. However, I'd still prefer that the new-non-hd-error is guarded by first-run. This way we can return early and don't have to deal with TopUpKeyPool, which might take a "long" time...
I don't think this whole check can be moved to before the first run block, as IsHDEnabled should be called after (a potential) SetHDMasterKey.
~Concept ACK~
utACK fadf31ef02b35f438ce2cf7048830f6974cdb515
utACK fadf31ef02b35f438ce2cf7048830f6974cdb515
3826 | @@ -3827,6 +3827,10 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile) 3827 | if (fFirstRun) 3828 | { 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));
Missing test?
3826 | @@ -3827,6 +3827,10 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile) 3827 | if (fFirstRun) 3828 | { 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;
Is it me or walletInstance is leaked?
I believe it is, but that is not a problem since the program just exits here. The same behavior happens earlier too with other InitErrors.
This needs a 0.16.0 milestone
utACK fadf31ef02b35f438ce2cf7048830f6974cdb515
Added 0.16 milestone.
is there a link to the relevant issue?
@instagibbs You can try it yourself with -usehd=0 or see #11313
Thanks, having the relevant issue in the PR description helps.
Milestone
0.16.0