Portable mode: set ringdb path

This commit is contained in:
tobtoht 2022-06-22 21:06:32 +02:00
parent 026dae8591
commit 1ae8009329
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
11 changed files with 58 additions and 30 deletions

View 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)

2
monero

@ -1 +1 @@
Subproject commit 2ab81abe7bea16f0f6da55da3b212f9ffbca8dcd
Subproject commit 4982ac420c101be2afb387138c4ee57b1a5c2f9b

View 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();

View 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) {

View 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)
{

View 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));
});
}

View 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);

View 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 applicationPath() {
QString applicationPath = qgetenv("APPIMAGE");
if (!applicationPath.isEmpty()) {
applicationPath = QFileInfo(applicationPath).absoluteDir().path();
} else {
applicationPath = QCoreApplication::applicationDirPath();
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 = 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;
}

View 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();

View 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()
{
}

View file

@ -123,7 +123,6 @@ public:
void resetToDefaults();
static QDir defaultConfigDir();
static QDir defaultPortableConfigDir();
static Config* instance();