aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QR-Code-scanner/Decoder.cpp14
-rw-r--r--src/libwalletqt/TransactionHistory.cpp31
-rw-r--r--src/libwalletqt/Wallet.cpp17
-rw-r--r--src/libwalletqt/Wallet.h1
-rw-r--r--src/main/oshelper.cpp6
-rw-r--r--src/main/oshelper.h1
-rw-r--r--src/p2pool/P2PoolManager.cpp24
-rw-r--r--src/qt/network.cpp12
8 files changed, 82 insertions, 24 deletions
diff --git a/src/QR-Code-scanner/Decoder.cpp b/src/QR-Code-scanner/Decoder.cpp
index 25ef0f04..57100006 100644
--- a/src/QR-Code-scanner/Decoder.cpp
+++ b/src/QR-Code-scanner/Decoder.cpp
@@ -28,6 +28,7 @@
#include "Decoder.h"
+#include <cstring>
#include <limits>
#include "quirc.h"
@@ -67,11 +68,14 @@ std::vector<std::string> QrDecoder::decodeGrayscale8(const QImage &image)
{
throw std::runtime_error("QUIRC: failed to get image buffer");
}
-#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
- std::copy(image.constBits(), image.constBits() + image.sizeInBytes(), rawImage);
-#else
- std::copy(image.constBits(), image.constBits() + image.byteCount(), rawImage);
-#endif
+
+ const int width = image.width();
+ const int height = image.height();
+ for (int y = 0; y < height; ++y)
+ {
+ std::memcpy(rawImage + y * width, image.constScanLine(y), width);
+ }
+
quirc_end(m_qr);
const int count = quirc_count(m_qr);
diff --git a/src/libwalletqt/TransactionHistory.cpp b/src/libwalletqt/TransactionHistory.cpp
index 764a3178..f5c3b752 100644
--- a/src/libwalletqt/TransactionHistory.cpp
+++ b/src/libwalletqt/TransactionHistory.cpp
@@ -36,6 +36,31 @@
#include <QWriteLocker>
#include <QtGlobal>
+namespace {
+ QString sanitizeCSVField(QString field)
+ {
+ field.remove(QChar('"'));
+
+ if (field.isEmpty()) {
+ return field;
+ }
+
+ const QChar first = field.at(0);
+ const bool needsPrefix =
+ first == QChar('=') ||
+ first == QChar('+') ||
+ first == QChar('-') ||
+ first == QChar('@') ||
+ first.isSpace() ||
+ first.category() == QChar::Other_Control;
+
+ if (needsPrefix) {
+ field.prepend(QChar('\''));
+ }
+
+ return field;
+ }
+}
bool TransactionHistory::transaction(int index, std::function<void (TransactionInfo &)> callback)
{
@@ -196,10 +221,8 @@ QString TransactionHistory::writeCSV(quint32 accountIndex, QString out)
else {
continue; // skip TransactionInfo::Direction_Both
}
- QString label = info.label();
- label.remove(QChar('"')); // reserved
- QString description = info.description();
- description.remove(QChar('"')); // reserved
+ QString label = sanitizeCSVField(info.label());
+ QString description = sanitizeCSVField(info.description());
quint64 blockHeight = info.blockHeight();
QDateTime timeStamp = info.timestamp();
QString date = info.date() + " " + info.time();
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp
index a5ac6925..bc086a16 100644
--- a/src/libwalletqt/Wallet.cpp
+++ b/src/libwalletqt/Wallet.cpp
@@ -536,7 +536,7 @@ void Wallet::setupBackgroundSync(const Wallet::BackgroundSyncType background_syn
pauseRefresh();
// run inside scheduler because of lag when stopping/starting refresh
- m_scheduler.run([this, refreshEnabled, background_sync_type, &wallet_password] {
+ m_scheduler.run([this, refreshEnabled, background_sync_type, wallet_password] {
m_walletImpl->setupBackgroundSync(
static_cast<Monero::Wallet::BackgroundSyncType>(background_sync_type),
wallet_password.toStdString(),
@@ -620,6 +620,19 @@ void Wallet::startRefresh()
qDebug() << "Starting refresh";
m_refreshEnabled = true;
m_refreshNow = true;
+
+ if (!m_refreshThreadStarted.exchange(true))
+ {
+ try
+ {
+ startRefreshThread();
+ }
+ catch (...)
+ {
+ m_refreshThreadStarted.store(false);
+ throw;
+ }
+ }
}
void Wallet::pauseRefresh()
@@ -1182,6 +1195,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
, m_refreshNow(false)
, m_refreshEnabled(false)
, m_refreshing(false)
+ , m_refreshThreadStarted(false)
, m_scheduler(this)
{
m_walletListener = new WalletListenerImpl(this);
@@ -1195,7 +1209,6 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
m_daemonUsername = "";
m_daemonPassword = "";
- startRefreshThread();
}
Wallet::~Wallet()
diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h
index a5bb913c..e41540ea 100644
--- a/src/libwalletqt/Wallet.h
+++ b/src/libwalletqt/Wallet.h
@@ -493,6 +493,7 @@ private:
std::atomic<bool> m_refreshNow;
std::atomic<bool> m_refreshEnabled;
std::atomic<bool> m_refreshing;
+ std::atomic<bool> m_refreshThreadStarted;
WalletListenerImpl *m_walletListener;
FutureScheduler m_scheduler;
};
diff --git a/src/main/oshelper.cpp b/src/main/oshelper.cpp
index 2ca0e400..cb9aca7a 100644
--- a/src/main/oshelper.cpp
+++ b/src/main/oshelper.cpp
@@ -248,6 +248,12 @@ QString OSHelper::temporaryPath() const
return QDir::tempPath();
}
+bool OSHelper::isWritableDirectory(const QString &path) const
+{
+ const QFileInfo info(path);
+ return info.exists() && info.isDir() && info.isWritable();
+}
+
QString OSHelper::randomPassword(int numBytes) const
{
numBytes = qBound(16, numBytes, 128);
diff --git a/src/main/oshelper.h b/src/main/oshelper.h
index 1c3aeb72..b6e98d32 100644
--- a/src/main/oshelper.h
+++ b/src/main/oshelper.h
@@ -51,6 +51,7 @@ public:
Q_INVOKABLE QString openSaveFileDialog(const QString &title, const QString &folder, const QString &filename) const;
Q_INVOKABLE QString temporaryFilename() const;
Q_INVOKABLE QString temporaryPath() const;
+ Q_INVOKABLE bool isWritableDirectory(const QString &path) const;
Q_INVOKABLE QString randomPassword(int numBytes = 32) const;
Q_INVOKABLE bool removeTemporaryWallet(const QString &walletName) const;
Q_INVOKABLE bool isCapsLock() const;
diff --git a/src/p2pool/P2PoolManager.cpp b/src/p2pool/P2PoolManager.cpp
index cf1af558..64414f0c 100644
--- a/src/p2pool/P2PoolManager.cpp
+++ b/src/p2pool/P2PoolManager.cpp
@@ -55,21 +55,21 @@ void P2PoolManager::download() {
QString fileName;
QString validHash;
#ifdef Q_OS_WIN
- url = "https://github.com/SChernykh/p2pool/releases/download/v4.15/p2pool-v4.15-windows-x64.zip";
- fileName = m_p2poolPath + "/p2pool-v4.15-windows-x64.zip";
- validHash = "c131d1ebf8658780f632276db587866f9e0d6d7952c04135fb0559c76249541e";
+ url = "https://github.com/SChernykh/p2pool/releases/download/v4.17.1/p2pool-v4.17.1-windows-x64.zip";
+ fileName = m_p2poolPath + "/p2pool-v4.17.1-windows-x64.zip";
+ validHash = "984822dd8a4645ea68763888d2127085bbb53ed42b35e1f899883b3a35a40a76";
#elif defined(Q_OS_LINUX)
- url = "https://github.com/SChernykh/p2pool/releases/download/v4.15/p2pool-v4.15-linux-x64.tar.gz";
- fileName = m_p2poolPath + "/p2pool-v4.15-linux-x64.tar.gz";
- validHash = "1611a159b4f60e12d9dc9650597cbe831961a123621216349d764f620cdff34b";
+ url = "https://github.com/SChernykh/p2pool/releases/download/v4.17.1/p2pool-v4.17.1-linux-x64.tar.gz";
+ fileName = m_p2poolPath + "/p2pool-v4.17.1-linux-x64.tar.gz";
+ validHash = "66b67fd8c7f00d33e76b3fa8373e67a5880a530ff1812aaf39aa85298d328f6c";
#elif defined(Q_OS_MACOS_AARCH64)
- url = "https://github.com/SChernykh/p2pool/releases/download/v4.15/p2pool-v4.15-macos-aarch64.tar.gz";
- fileName = m_p2poolPath + "/p2pool-v4.15-macos-aarch64.tar.gz";
- validHash = "14211494a9d0adce8547c77eb75c5f86f8608dfbb4fa0e80b1967ece0dc916b5";
+ url = "https://github.com/SChernykh/p2pool/releases/download/v4.17.1/p2pool-v4.17.1-macos-aarch64.tar.gz";
+ fileName = m_p2poolPath + "/p2pool-v4.17.1-macos-aarch64.tar.gz";
+ validHash = "8b8454fb4d8330b4a039d4657be69c8543a22938a8957c083512be41e27016b1";
#elif defined(Q_OS_MACOS)
- url = "https://github.com/SChernykh/p2pool/releases/download/v4.15/p2pool-v4.15-macos-x64.tar.gz";
- fileName = m_p2poolPath + "/p2pool-v4.15-macos-x64.tar.gz";
- validHash = "a358489a4b1a6addfcc86ff235a0ce50210899f5e3a6dc93ce0eb69e0d181564";
+ url = "https://github.com/SChernykh/p2pool/releases/download/v4.17.1/p2pool-v4.17.1-macos-x64.tar.gz";
+ fileName = m_p2poolPath + "/p2pool-v4.17.1-macos-x64.tar.gz";
+ validHash = "64657dd2ae954d41880aef98193124d1d08dfa2e991f755a9d089a35f96def13";
#endif
QFile file(fileName);
epee::net_utils::http::http_simple_client http_client;
diff --git a/src/qt/network.cpp b/src/qt/network.cpp
index ba6c94d6..574369c9 100644
--- a/src/qt/network.cpp
+++ b/src/qt/network.cpp
@@ -144,7 +144,17 @@ QString Network::get(
const QString &contentType /* = {} */) const
{
const QUrl urlParsed(url);
- httpClient->set_server(urlParsed.host().toStdString(), urlParsed.scheme() == "https" ? "443" : "80", {});
+ const bool isHttps = urlParsed.scheme() == "https";
+
+ const auto sslSupport = isHttps
+ ? epee::net_utils::ssl_support_t::e_ssl_support_enabled
+ : epee::net_utils::ssl_support_t::e_ssl_support_disabled;
+
+ httpClient->set_server(
+ urlParsed.host().toStdString(),
+ std::to_string(urlParsed.port(isHttps ? 443 : 80)),
+ {},
+ epee::net_utils::ssl_options_t{sslSupport});
const QString uri = (urlParsed.hasQuery() ? urlParsed.path() + "?" + urlParsed.query() : urlParsed.path());
const http_response_info *pri = NULL;