]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
Portable mode: set ringdb path
authortobtoht <thotbot@protonmail.com>
Wed, 22 Jun 2022 19:06:32 +0000 (21:06 +0200)
committertobtoht <thotbot@protonmail.com>
Wed, 22 Jun 2022 19:37:27 +0000 (21:37 +0200)
CMakeLists.txt
monero
src/SettingsDialog.cpp
src/WindowManager.cpp
src/cli.cpp
src/libwalletqt/WalletManager.cpp
src/libwalletqt/WalletManager.h
src/utils/Utils.cpp
src/utils/Utils.h
src/utils/config.cpp
src/utils/config.h

index 7a3673ca6ead7621c426e9b2f7da19a025e495a1..735bfe9cd3abfea0be5547e93b7e7b9aa3fb056c 100644 (file)
@@ -33,7 +33,7 @@ if(DEBUG)
     set(CMAKE_VERBOSE_MAKEFILE ON)
 endif()
 
-set(MONERO_HEAD "2ab81abe7bea16f0f6da55da3b212f9ffbca8dcd")
+set(MONERO_HEAD "4982ac420c101be2afb387138c4ee57b1a5c2f9b")
 set(BUILD_GUI_DEPS ON)
 option(ARCH "Target architecture" "native")
 set(BUILD_64 ON)
diff --git a/monero b/monero
index 2ab81abe7bea16f0f6da55da3b212f9ffbca8dcd..4982ac420c101be2afb387138c4ee57b1a5c2f9b 160000 (submodule)
--- a/monero
+++ b/monero
@@ -1 +1 @@
-Subproject commit 2ab81abe7bea16f0f6da55da3b212f9ffbca8dcd
+Subproject commit 4982ac420c101be2afb387138c4ee57b1a5c2f9b
index 569f13f690771f37d265e1524e579c7bf7d0b5c0..d4f2fec8c4c65328c52b36b141d2eeba1fdfcff8 100644 (file)
@@ -159,7 +159,7 @@ void Settings::setupNodeTab() {
 void Settings::setupPathsTab() {
     ui->lineEdit_defaultWalletDir->setText(config()->get(Config::walletDirectory).toString());
     ui->lineEdit_configDir->setText(Config::defaultConfigDir().path());
-    ui->lineEdit_applicationDir->setText(QCoreApplication::applicationDirPath());
+    ui->lineEdit_applicationDir->setText(Utils::applicationPath());
 
     connect(ui->btn_browseDefaultWalletDir, &QPushButton::clicked, [this]{
         QString walletDirOld = config()->get(Config::walletDirectory).toString();
index 414eb84df95fb60acb5519486b2be6d1b11bc604..64978a387dd36d2441f013e42b9a2ffbf4e9cc02 100644 (file)
@@ -156,7 +156,7 @@ void WindowManager::tryOpenWallet(const QString &path, const QString &password)
     }
 
     m_openingWallet = true;
-    m_walletManager->openWalletAsync(path, password, constants::networkType, 1);
+    m_walletManager->openWalletAsync(path, password, constants::networkType, constants::kdfRounds, Utils::ringDatabasePath());
 }
 
 void WindowManager::onWalletOpened(Wallet *wallet) {
index 79c4cd4c71b98a52766f059cb657481a9388d556..0ca825c09ae414e043714e4c57f13721b7ddd7a0 100644 (file)
@@ -9,6 +9,7 @@
 #include "model/AddressBookModel.h"
 #include "model/TransactionHistoryModel.h"
 #include "utils/brute.h"
+#include "utils/Utils.h"
 #include "constants.h"
 
 CLI::CLI(Mode mode, QCommandLineParser *cmdargs, QObject *parent)
@@ -34,7 +35,7 @@ CLI::CLI(Mode mode, QCommandLineParser *cmdargs, QObject *parent)
         QString password = cmdargs->value("password");
 
 
-        m_walletManager->openWalletAsync(walletFile, password, constants::networkType);
+        m_walletManager->openWalletAsync(walletFile, password, constants::networkType, constants::kdfRounds, Utils::ringDatabasePath());
     }
     else if (mode == Mode::BruteforcePassword)
     {
index 109f8c9620cdb8a14847728b755d546acd62f037..3273e6896625716cbeebd28a4e5778cf64e26d0f 100644 (file)
@@ -74,7 +74,7 @@ Wallet *WalletManager::createWallet(const QString &path, const QString &password
     return new Wallet(w);
 }
 
-Wallet *WalletManager::openWallet(const QString &path, const QString &password, NetworkType::Type nettype, quint64 kdfRounds)
+Wallet *WalletManager::openWallet(const QString &path, const QString &password, NetworkType::Type nettype, quint64 kdfRounds, const QString &ringDatabasePath)
 {
     QMutexLocker locker(&m_mutex);
     WalletPassphraseListenerImpl tmpListener(this);
@@ -88,7 +88,7 @@ Wallet *WalletManager::openWallet(const QString &path, const QString &password,
 
     qDebug() << QString("%1: opening wallet at %2, nettype = %3 ").arg(__PRETTY_FUNCTION__).arg(qPrintable(path)).arg(nettype);
 
-    Monero::Wallet * w =  m_pimpl->openWallet(path.toStdString(), password.toStdString(), static_cast<Monero::NetworkType>(nettype), kdfRounds, &tmpListener);
+    Monero::Wallet * w = m_pimpl->openWallet(path.toStdString(), password.toStdString(), static_cast<Monero::NetworkType>(nettype), kdfRounds, ringDatabasePath.toStdString(), &tmpListener);
     w->setListener(nullptr);
 
     qDebug() << QString("%1: opened wallet: %2, status: %3").arg(__PRETTY_FUNCTION__).arg(w->address(0, 0).c_str()).arg(w->status());
@@ -102,10 +102,10 @@ Wallet *WalletManager::openWallet(const QString &path, const QString &password,
     return wallet;
 }
 
-void WalletManager::openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype, quint64 kdfRounds)
+void WalletManager::openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype, quint64 kdfRounds, const QString &ringDatabasePath)
 {
-    m_scheduler.run([this, path, password, nettype, kdfRounds] {
-        emit walletOpened(openWallet(path, password, nettype, kdfRounds));
+    m_scheduler.run([this, path, password, nettype, kdfRounds, ringDatabasePath] {
+        emit walletOpened(openWallet(path, password, nettype, kdfRounds, ringDatabasePath));
     });
 }
 
index 626ccfce838400c4eaa21b15b54a196cc9692aa8..6390b49b56027b4875f7d57f136f7f58577d632f 100644 (file)
@@ -35,13 +35,13 @@ public:
      * \param nettype    - type of network the wallet is running on
      * \return wallet object pointer
      */
-    Wallet * openWallet(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
+    Wallet * openWallet(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1, const QString &ringDatabasePath = "");
 
     /*!
      * \brief openWalletAsync - asynchronous version of "openWallet". Returns immediately. "walletOpened" signal
      *                          emitted when wallet opened;
      */
-    void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1);
+    void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET, quint64 kdfRounds = 1, const QString &ringDatabasePath = "");
 
     Wallet * recoveryWallet(const QString &path, const QString &password, const QString &seed, const QString &seed_offset,
                             NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1);
index 997fb4af941e556bc45a8f1b289dc822295d2dc9..f241f0b689bbc5df409e5a8c2f0ba89b464dfac6 100644 (file)
@@ -102,6 +102,14 @@ bool dirExists(const QString &path) {
     return pathDir.exists();
 }
 
+QString portablePath() {
+    return Utils::applicationPath() + "/feather_data";
+}
+
+bool isPortableMode() {
+    return Utils::portableFileExists(Utils::applicationPath());
+}
+
 bool portableFileExists(const QString &dir) {
     QStringList portableFiles = {".portable", ".portable.txt", "portable.txt"};
 
@@ -111,9 +119,8 @@ bool portableFileExists(const QString &dir) {
 }
 
 QString defaultWalletDir() {
-    QString portablePath = QCoreApplication::applicationDirPath();
-    if (Utils::portableFileExists(portablePath)) {
-        return portablePath + "/feather_data/wallets";
+    if (Utils::isPortableMode()) {
+        return Utils::portablePath() + "/wallets";
     }
 
     if (TailsOS::detect()) {
@@ -145,13 +152,35 @@ QString defaultWalletDir() {
     return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/wallets";
 }
 
+QString ringDatabasePath() {
+    if (Utils::isPortableMode()) {
+        QString suffix = "";
+        if (constants::networkType != NetworkType::Type::MAINNET) {
+            suffix = "-" + Utils::QtEnumToString(constants::networkType);
+        }
+        return Utils::portablePath() + "/ringdb" + suffix;
+    }
+    return ""; // Use libwallet default
+}
+
 QString applicationPath() {
-    QString applicationPath = qgetenv("APPIMAGE");
-    if (!applicationPath.isEmpty()) {
-        applicationPath = QFileInfo(applicationPath).absoluteDir().path();
-    } else {
-        applicationPath = QCoreApplication::applicationDirPath();
+    QString applicationPath = QCoreApplication::applicationDirPath();
+    QDir appDir(applicationPath);
+
+#ifdef Q_OS_MACOS
+    // applicationDirPath will be inside the app bundle
+
+    if (applicationPath.endsWith("Contents/MacOS")) {
+        appDir.cd("../../..");
     }
+    return appDir.absolutePath();
+#endif
+
+    QString appimagePath = qgetenv("APPIMAGE");
+    if (!appimagePath.isEmpty()) {
+        return QFileInfo(appimagePath).absoluteDir().path();
+    }
+
     return applicationPath;
 }
 
index ecdf80639f1ac4ee7fdad6f09c124a12272faff9..badd61809a1aa2101bc603356b8377e3324858e8 100644 (file)
@@ -21,8 +21,12 @@ namespace Utils
     bool pixmapWrite(const QString &path, const QPixmap &pixmap);
     QStringList fileFind(const QRegularExpression &pattern, const QString &baseDir, int level, int depth, int maxPerDir);
 
-    bool dirExists(const QString &path);
+    QString portablePath();
+    bool isPortableMode();
     bool portableFileExists(const QString &dir);
+    QString ringDatabasePath();
+
+    bool dirExists(const QString &path);
     QString defaultWalletDir();
     QString applicationPath();
 
index dfdda0286358ec5e109feb9a23fb6f357fe38bda..426f96bfe92510476c037db1aeb7a4aa8a46e0f2 100644 (file)
@@ -168,9 +168,8 @@ Config::Config(QObject* parent)
 }
 
 QDir Config::defaultConfigDir() {
-    QString portablePath = QCoreApplication::applicationDirPath();
-    if (Utils::portableFileExists(portablePath)) {
-        return portablePath + "/feather_data";
+    if (Utils::isPortableMode()) {
+        return Utils::portablePath();
     }
 
     if (TailsOS::detect()) {
@@ -204,10 +203,6 @@ QDir Config::defaultConfigDir() {
 #endif
 }
 
-QDir Config::defaultPortableConfigDir() {
-    return QDir(QCoreApplication::applicationDirPath() + "/feather_data");
-}
-
 Config::~Config()
 {
 }
index f0131ae96a1ce3af57536f8453a34699b05209eb..cc3ca7ff777985064c005d169099b951dea563ef 100644 (file)
@@ -123,7 +123,6 @@ public:
     void resetToDefaults();
 
     static QDir defaultConfigDir();
-    static QDir defaultPortableConfigDir();
 
     static Config* instance();