diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6e52d23a876fc..5a97574813442 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -298,7 +298,7 @@ std::shared_ptr CreateWallet(interfaces::Chain& chain, interfaces::Coin return nullptr; } if (gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET)) { - LogPrintf("set HD by default\n"); + wallet->WalletLogPrintf("Set HD by default\n"); wallet->SetMinVersion(FEATURE_HD); } @@ -310,13 +310,6 @@ std::shared_ptr CreateWallet(interfaces::Chain& chain, interfaces::Coin return nullptr; } if (!create_blank) { - // Unlock the wallet - if (!wallet->Unlock(passphrase)) { - error = Untranslated("Error: Wallet was encrypted but could not be unlocked"); - status = DatabaseStatus::FAILED_ENCRYPT; - return nullptr; - } - { // TODO: drop this condition after removing option to create non-HD wallets // related backport bitcoin#11250 @@ -329,6 +322,13 @@ std::shared_ptr CreateWallet(interfaces::Chain& chain, interfaces::Coin } } + // Unlock the wallet + if (!wallet->Unlock(passphrase)) { + error = Untranslated("Error: Wallet was encrypted but could not be unlocked"); + status = DatabaseStatus::FAILED_ENCRYPT; + return nullptr; + } + // backup the wallet we just encrypted if (!wallet->AutoBackupWallet("", error, warnings) && !error.original.empty()) { status = DatabaseStatus::FAILED_ENCRYPT;