mirror of
https://github.com/feather-wallet/feather.git
synced 2024-11-16 17:27:38 +00:00
Portable mode: set ringdb path
This commit is contained in:
parent
026dae8591
commit
1ae8009329
11 changed files with 58 additions and 30 deletions
|
@ -33,7 +33,7 @@ if(DEBUG)
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MONERO_HEAD "2ab81abe7bea16f0f6da55da3b212f9ffbca8dcd")
|
set(MONERO_HEAD "4982ac420c101be2afb387138c4ee57b1a5c2f9b")
|
||||||
set(BUILD_GUI_DEPS ON)
|
set(BUILD_GUI_DEPS ON)
|
||||||
option(ARCH "Target architecture" "native")
|
option(ARCH "Target architecture" "native")
|
||||||
set(BUILD_64 ON)
|
set(BUILD_64 ON)
|
||||||
|
|
2
monero
2
monero
|
@ -1 +1 @@
|
||||||
Subproject commit 2ab81abe7bea16f0f6da55da3b212f9ffbca8dcd
|
Subproject commit 4982ac420c101be2afb387138c4ee57b1a5c2f9b
|
|
@ -159,7 +159,7 @@ void Settings::setupNodeTab() {
|
||||||
void Settings::setupPathsTab() {
|
void Settings::setupPathsTab() {
|
||||||
ui->lineEdit_defaultWalletDir->setText(config()->get(Config::walletDirectory).toString());
|
ui->lineEdit_defaultWalletDir->setText(config()->get(Config::walletDirectory).toString());
|
||||||
ui->lineEdit_configDir->setText(Config::defaultConfigDir().path());
|
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]{
|
connect(ui->btn_browseDefaultWalletDir, &QPushButton::clicked, [this]{
|
||||||
QString walletDirOld = config()->get(Config::walletDirectory).toString();
|
QString walletDirOld = config()->get(Config::walletDirectory).toString();
|
||||||
|
|
|
@ -156,7 +156,7 @@ void WindowManager::tryOpenWallet(const QString &path, const QString &password)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_openingWallet = true;
|
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) {
|
void WindowManager::onWalletOpened(Wallet *wallet) {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "model/AddressBookModel.h"
|
#include "model/AddressBookModel.h"
|
||||||
#include "model/TransactionHistoryModel.h"
|
#include "model/TransactionHistoryModel.h"
|
||||||
#include "utils/brute.h"
|
#include "utils/brute.h"
|
||||||
|
#include "utils/Utils.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
|
||||||
CLI::CLI(Mode mode, QCommandLineParser *cmdargs, QObject *parent)
|
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");
|
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)
|
else if (mode == Mode::BruteforcePassword)
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,7 +74,7 @@ Wallet *WalletManager::createWallet(const QString &path, const QString &password
|
||||||
return new Wallet(w);
|
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);
|
QMutexLocker locker(&m_mutex);
|
||||||
WalletPassphraseListenerImpl tmpListener(this);
|
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);
|
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);
|
w->setListener(nullptr);
|
||||||
|
|
||||||
qDebug() << QString("%1: opened wallet: %2, status: %3").arg(__PRETTY_FUNCTION__).arg(w->address(0, 0).c_str()).arg(w->status());
|
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;
|
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] {
|
m_scheduler.run([this, path, password, nettype, kdfRounds, ringDatabasePath] {
|
||||||
emit walletOpened(openWallet(path, password, nettype, kdfRounds));
|
emit walletOpened(openWallet(path, password, nettype, kdfRounds, ringDatabasePath));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,13 @@ public:
|
||||||
* \param nettype - type of network the wallet is running on
|
* \param nettype - type of network the wallet is running on
|
||||||
* \return wallet object pointer
|
* \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
|
* \brief openWalletAsync - asynchronous version of "openWallet". Returns immediately. "walletOpened" signal
|
||||||
* emitted when wallet opened;
|
* 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,
|
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);
|
NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0, quint64 kdfRounds = 1);
|
||||||
|
|
|
@ -102,6 +102,14 @@ bool dirExists(const QString &path) {
|
||||||
return pathDir.exists();
|
return pathDir.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString portablePath() {
|
||||||
|
return Utils::applicationPath() + "/feather_data";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isPortableMode() {
|
||||||
|
return Utils::portableFileExists(Utils::applicationPath());
|
||||||
|
}
|
||||||
|
|
||||||
bool portableFileExists(const QString &dir) {
|
bool portableFileExists(const QString &dir) {
|
||||||
QStringList portableFiles = {".portable", ".portable.txt", "portable.txt"};
|
QStringList portableFiles = {".portable", ".portable.txt", "portable.txt"};
|
||||||
|
|
||||||
|
@ -111,9 +119,8 @@ bool portableFileExists(const QString &dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString defaultWalletDir() {
|
QString defaultWalletDir() {
|
||||||
QString portablePath = QCoreApplication::applicationDirPath();
|
if (Utils::isPortableMode()) {
|
||||||
if (Utils::portableFileExists(portablePath)) {
|
return Utils::portablePath() + "/wallets";
|
||||||
return portablePath + "/feather_data/wallets";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TailsOS::detect()) {
|
if (TailsOS::detect()) {
|
||||||
|
@ -145,13 +152,35 @@ QString defaultWalletDir() {
|
||||||
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/wallets";
|
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/wallets";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString applicationPath() {
|
QString ringDatabasePath() {
|
||||||
QString applicationPath = qgetenv("APPIMAGE");
|
if (Utils::isPortableMode()) {
|
||||||
if (!applicationPath.isEmpty()) {
|
QString suffix = "";
|
||||||
applicationPath = QFileInfo(applicationPath).absoluteDir().path();
|
if (constants::networkType != NetworkType::Type::MAINNET) {
|
||||||
} else {
|
suffix = "-" + Utils::QtEnumToString(constants::networkType);
|
||||||
applicationPath = QCoreApplication::applicationDirPath();
|
|
||||||
}
|
}
|
||||||
|
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;
|
return applicationPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,12 @@ namespace Utils
|
||||||
bool pixmapWrite(const QString &path, const QPixmap &pixmap);
|
bool pixmapWrite(const QString &path, const QPixmap &pixmap);
|
||||||
QStringList fileFind(const QRegularExpression &pattern, const QString &baseDir, int level, int depth, int maxPerDir);
|
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);
|
bool portableFileExists(const QString &dir);
|
||||||
|
QString ringDatabasePath();
|
||||||
|
|
||||||
|
bool dirExists(const QString &path);
|
||||||
QString defaultWalletDir();
|
QString defaultWalletDir();
|
||||||
QString applicationPath();
|
QString applicationPath();
|
||||||
|
|
||||||
|
|
|
@ -168,9 +168,8 @@ Config::Config(QObject* parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir Config::defaultConfigDir() {
|
QDir Config::defaultConfigDir() {
|
||||||
QString portablePath = QCoreApplication::applicationDirPath();
|
if (Utils::isPortableMode()) {
|
||||||
if (Utils::portableFileExists(portablePath)) {
|
return Utils::portablePath();
|
||||||
return portablePath + "/feather_data";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TailsOS::detect()) {
|
if (TailsOS::detect()) {
|
||||||
|
@ -204,10 +203,6 @@ QDir Config::defaultConfigDir() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir Config::defaultPortableConfigDir() {
|
|
||||||
return QDir(QCoreApplication::applicationDirPath() + "/feather_data");
|
|
||||||
}
|
|
||||||
|
|
||||||
Config::~Config()
|
Config::~Config()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,6 @@ public:
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
|
||||||
static QDir defaultConfigDir();
|
static QDir defaultConfigDir();
|
||||||
static QDir defaultPortableConfigDir();
|
|
||||||
|
|
||||||
static Config* instance();
|
static Config* instance();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue