From 8756130fa64524e643332fb103a2557ee8a60f31 Mon Sep 17 00:00:00 2001 From: random-zebra Date: Fri, 23 Jul 2021 22:24:31 +0200 Subject: [PATCH] [BUG] Fix broken tutorial wizard The `-wallet` arguments can now represent paths to existing directories or symlinks (by default it is empty, representing the path relative to the datadir, i.e. the datadir itself). It does not include the *filename* (unless explicitely specified in `-wallet`) anymore. Therefore the tutorial screen is never created (even on fresh installs). Also, we are using `GetArg`, which returns the last argument from command line (or first argument in conf file), and not checking all the files with `GetArgs`. --- src/qt/pivx.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/qt/pivx.cpp b/src/qt/pivx.cpp index 15c38ab1c2bd..668c6a61295a 100644 --- a/src/qt/pivx.cpp +++ b/src/qt/pivx.cpp @@ -683,13 +683,22 @@ int main(int argc, char* argv[]) bool ret = true; #ifdef ENABLE_WALLET - // Check if at least one wallet exists or needs to be created - const std::string& strWalletFile = gArgs.GetArg("-wallet", ""); - auto opRes = VerifyWalletPath(strWalletFile); - if (!opRes) throw std::runtime_error(opRes.getError()); - - if (!fs::exists(fs::absolute(strWalletFile, GetWalletDir()))) { - // wallet doesn't exist, popup tutorial screen. + // Check if at least one wallet exists, otherwise prompt tutorial + bool createTutorial{true}; + const fs::path wallet_dir = GetWalletDir(); + for (const std::string& wallet_name : gArgs.GetArgs("-wallet")) { + auto opRes = VerifyWalletPath(wallet_name); + if (!opRes) throw std::runtime_error(opRes.getError()); + fs::path wallet_path = fs::absolute(wallet_name, wallet_dir); + if (!fs::is_regular_file(wallet_path)) { + wallet_path /= "wallet.dat"; + } + if (createTutorial && fs::exists(wallet_path)) { + // some wallet already exists, don't create tutorial + createTutorial = false; + } + } + if (createTutorial) { ret = app.createTutorialScreen(); } #endif