Misc code cleanup

master
tobtoht 4 years ago
parent f488dd9116
commit b758cc1918
Signed by untrusted user: tobtoht
GPG Key ID: 1CADD27F41F45C3C

@ -1,35 +1,19 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <stdexcept>
#include <QDir>
#include <QStandardPaths>
#include <QMessageBox>
#include <QClipboard>
#include <QDesktopWidget>
#include "appcontext.h"
#include "globals.h"
#include "utils/tails.h"
#include "utils/whonix.h"
#include "utils/utils.h"
#include "utils/prices.h"
#include "utils/networktype.h"
#include "utils/wsclient.h"
#include "utils/config.h"
// libwalletqt
#include "libwalletqt/WalletManager.h"
#include "libwalletqt/Wallet.h"
#include "libwalletqt/TransactionHistory.h"
#include "libwalletqt/SubaddressAccount.h"
#include "libwalletqt/Subaddress.h"
#include "libwalletqt/Coins.h"
#include "model/TransactionHistoryModel.h"
#include "model/SubaddressAccountModel.h"
#include "model/SubaddressModel.h"
#include "utils/keysfiles.h"
#include "utils/networktype.h"
Prices *AppContext::prices = nullptr;
@ -125,8 +109,8 @@ AppContext::AppContext(QCommandLineParser *cmdargs) {
connect(this->ws, &WSClient::WSMessage, this, &AppContext::onWSMessage);
// timers
m_storeTimer->setSingleShot(true);
connect(this->m_storeTimer, &QTimer::timeout, [this](){
m_storeTimer.setSingleShot(true);
connect(&m_storeTimer, &QTimer::timeout, [this](){
if (!this->currentWallet)
return;
qDebug() << "Storing wallet";
@ -186,7 +170,7 @@ void AppContext::initTor() {
this->tor->start();
if (!(isWhonix)) {
auto networkProxy = new QNetworkProxy(QNetworkProxy::Socks5Proxy, Tor::torHost, Tor::torPort);
this->networkProxy = new QNetworkProxy(QNetworkProxy::Socks5Proxy, Tor::torHost, Tor::torPort);
this->network->setProxy(*networkProxy);
if (m_wsUrl.host().endsWith(".onion"))
this->ws->webSocket.setProxy(*networkProxy);
@ -301,7 +285,6 @@ void AppContext::onPreferredFiatCurrencyChanged(const QString &symbol) {
if(this->currentWallet) {
auto *model = this->currentWallet->transactionHistoryModel();
if(model != nullptr) {
model->preferredFiatSign = AppContext::prices->fiat[symbol];
model->preferredFiatSymbol = symbol;
}
}
@ -344,7 +327,6 @@ void AppContext::onWalletOpened(Wallet *wallet) {
connect(this->currentWallet, &Wallet::transactionCommitted, this, &AppContext::onTransactionCommitted);
connect(this->currentWallet, &Wallet::heightRefreshed, this, &AppContext::onHeightRefreshed);
connect(this->currentWallet, &Wallet::transactionCreated, this, &AppContext::onTransactionCreated);
connect(this->currentWallet, &Wallet::connectionStatusChanged, this, &AppContext::onConnectionStatusChanged);
emit walletOpened();
@ -787,15 +769,11 @@ void AppContext::onTransactionCommitted(bool status, PendingTransaction *tx, con
}
}
void AppContext::onConnectionStatusChanged(int status) {
}
void AppContext::storeWallet() {
if (m_storeTimer->isActive())
if (m_storeTimer.isActive())
return;
m_storeTimer->start(60000);
m_storeTimer.start(60000);
}
void AppContext::updateBalance() {

@ -35,7 +35,7 @@ Q_OBJECT
public:
explicit AppContext(QCommandLineParser *cmdargs);
~AppContext();
~AppContext() override;
bool isTails = false;
bool isWhonix = false;
bool isDebug = false;
@ -75,9 +75,9 @@ public:
QNetworkAccessManager *network;
QNetworkAccessManager *networkClearnet;
QNetworkProxy *networkProxy;
QNetworkProxy *networkProxy{};
Tor *tor;
Tor *tor{};
WSClient *ws;
XmrTo *XMRTo;
XmRig *XMRig;
@ -109,7 +109,7 @@ public:
public slots:
void onOpenWallet(const QString& path, const QString &password);
void onCreateTransaction(const QString &address, const double amount, const QString &description, bool all);
void onCreateTransaction(const QString &address, double amount, const QString &description, bool all);
void onCreateTransaction(XmrToOrder *order);
void onCancelTransaction(PendingTransaction *tx, const QString &address);
void onSweepOutput(const QString &keyImage, QString address, bool churn, int outputs) const;
@ -134,7 +134,6 @@ private slots:
void onHeightRefreshed(quint64 walletHeight, quint64 daemonHeight, quint64 targetHeight);
void onTransactionCreated(PendingTransaction *tx, const QString &address, const QString &paymentId, quint32 mixin);
void onTransactionCommitted(bool status, PendingTransaction *t, const QStringList& txid);
void onConnectionStatusChanged(int status);
signals:
void balanceUpdated(quint64 balance, quint64 spendable);
@ -173,8 +172,8 @@ signals:
private:
const int m_donationBoundary = 15;
UtilsNetworking *m_utilsNetworkingNodes;
QTimer *m_storeTimer = new QTimer(this);
UtilsNetworking *m_utilsNetworkingNodes{};
QTimer m_storeTimer;
QUrl m_wsUrl = QUrl(QStringLiteral("ws://7e6egbawekbkxzkv4244pqeqgoo4axko2imgjbedwnn6s5yb6b7oliqd.onion/ws"));
};

@ -5,7 +5,6 @@
#include "calcwidget.h"
#include "ui_calcwidget.h"
#include "utils/config.h"
#include "mainwindow.h"
CalcWidget::CalcWidget(QWidget *parent) :

@ -17,7 +17,7 @@ Q_OBJECT
public:
explicit CalcWidget(QWidget *parent = nullptr);
~CalcWidget();
~CalcWidget() override;
signals:
void closed();

@ -4,17 +4,9 @@
#include "cli.h"
// libwalletqt
#include "Wallet.h"
#include "libwalletqt/TransactionHistory.h"
#include "libwalletqt/SubaddressAccount.h"
#include "libwalletqt/Subaddress.h"
#include "libwalletqt/AddressBook.h"
#include "libwalletqt/Coins.h"
#include "model/AddressBookModel.h"
#include "model/TransactionHistoryModel.h"
#include "model/SubaddressAccountModel.h"
#include "model/SubaddressModel.h"
#include "model/CoinsModel.h"
CLI::CLI(AppContext *ctx, QObject *parent) :
QObject(parent),

@ -3,17 +3,11 @@
#include "coinswidget.h"
#include "ui_coinswidget.h"
#include "model/ModelUtils.h"
#include "utils/utils.h"
#include "dialog/outputinfodialog.h"
#include "dialog/outputsweepdialog.h"
#include "mainwindow.h"
#include <QClipboard>
#include <QDebug>
#include <QKeyEvent>
#include <QMenu>
#include <QAction>
#include <QMessageBox>
CoinsWidget::CoinsWidget(QWidget *parent)

@ -3,7 +3,6 @@
#include "broadcasttxdialog.h"
#include "ui_broadcasttxdialog.h"
#include "utils/nodes.h"
#include <QMessageBox>

@ -4,10 +4,6 @@
#include "debuginfodialog.h"
#include "ui_debuginfodialog.h"
#include "config-feather.h"
#include "utils/utils.h"
#include <QDateTime>
#include <QSysInfo>
DebugInfoDialog::DebugInfoDialog(AppContext *ctx, QWidget *parent)
: QDialog(parent)

@ -4,11 +4,8 @@
#include "outputinfodialog.h"
#include "ui_outputinfodialog.h"
#include "model/ModelUtils.h"
#include "libwalletqt/CoinsInfo.h"
#include "utils/utils.h"
#include <QFont>
OutputInfoDialog::OutputInfoDialog(CoinsInfo *cInfo, QWidget *parent)
: QDialog(parent)
, ui(new Ui::OutputInfoDialog)

@ -4,7 +4,6 @@
#include "passwordchangedialog.h"
#include "ui_passwordchangedialog.h"
#include <QPushButton>
#include <QMessageBox>
PasswordChangeDialog::PasswordChangeDialog(QWidget *parent, Wallet *wallet)

@ -3,7 +3,6 @@
#include "qrcodedialog.h"
#include "ui_qrcodedialog.h"
#include "qrcode/QrCode.h"
#include <QClipboard>
#include <QFileDialog>

@ -3,8 +3,6 @@
#include "restoredialog.h"
#include "ui_restoredialog.h"
#include "utils/utils.h"
#include "appcontext.h"
RestoreDialog::RestoreDialog(AppContext *ctx, QWidget *parent)
: QDialog(parent)

@ -3,11 +3,8 @@
#include "txconfadvdialog.h"
#include "ui_txconfadvdialog.h"
#include "libwalletqt/WalletManager.h"
#include "qrcode/QrCode.h"
#include "dialog/qrcodedialog.h"
#include "utils/utils.h"
#include "libwalletqt/PendingTransactionInfo.h"
#include "libwalletqt/Transfer.h"
#include "libwalletqt/Input.h"
#include "model/ModelUtils.h"

@ -3,10 +3,7 @@
#include "txconfdialog.h"
#include "ui_txconfdialog.h"
#include "appcontext.h"
#include "utils/config.h"
#include "model/ModelUtils.h"
#include "libwalletqt/WalletManager.h"
#include "txconfadvdialog.h"
#include "globals.h"

@ -25,8 +25,6 @@ public:
private:
void setShowAdvanced();
void saveToFile();
void copyToClipboard();
Ui::TxConfDialog *ui;
AppContext *m_ctx;

@ -4,7 +4,6 @@
#include "verifyproofdialog.h"
#include "ui_verifyproofdialog.h"
#include "utils/utils.h"
#include "libwalletqt/WalletManager.h"
#include <QMessageBox>

@ -4,8 +4,6 @@
#include "xmrtoinfodialog.h"
#include "ui_xmrtoinfodialog.h"
#include <QFont>
XmrToInfoDialog::XmrToInfoDialog(XmrToOrder *oInfo, QWidget *parent)
: QDialog(parent)
, ui(new Ui::XmrToInfoDialog)

@ -4,10 +4,6 @@
#include "historywidget.h"
#include "ui_historywidget.h"
#include "dialog/transactioninfodialog.h"
#include "libwalletqt/TransactionHistory.h"
#include "model/TransactionHistoryProxyModel.h"
#include <QIcon>
HistoryWidget::HistoryWidget(QWidget *parent)
: QWidget(parent)

@ -2,7 +2,6 @@
// Copyright (c) 2014-2021, The Monero Project.
#include "AddressBook.h"
#include "AddressBookInfo.h"
#include <QDebug>
AddressBook::AddressBook(Monero::AddressBook *abImpl,QObject *parent)

@ -5,15 +5,9 @@
#include <QDebug>
#include "Coins.h"
#include "CoinsInfo.h"
#include <wallet/api/wallet2_api.h>
#include <QFile>
#include <QDebug>
#include <QReadLocker>
#include <QWriteLocker>
#include <QtGlobal>
bool Coins::coin(int index, std::function<void (CoinsInfo &)> callback)

@ -3,9 +3,6 @@
#include "CoinsInfo.h"
#include "libwalletqt/WalletManager.h"
#include "Transfer.h"
#include <QDateTime>
#include <QDebug>
quint64 CoinsInfo::blockHeight() const
{

@ -2,7 +2,6 @@
// Copyright (c) 2014-2021, The Monero Project.
#include "PassphraseHelper.h"
#include <QMutexLocker>
#include <QDebug>
Monero::optional<std::string> PassphraseHelper::onDevicePassphraseRequest(bool & on_device)

@ -2,8 +2,6 @@
// Copyright (c) 2014-2021, The Monero Project.
#include "PendingTransactionInfo.h"
#include "Input.h"
#include "Transfer.h"
quint64 PendingTransactionInfo::fee() const {
return m_fee;

@ -5,13 +5,6 @@
#include "TransactionInfo.h"
#include "utils/utils.h"
#include "appcontext.h"
#include <wallet/api/wallet2_api.h>
#include <QFile>
#include <QDebug>
#include <QReadLocker>
#include <QWriteLocker>
#include <QtGlobal>
bool TransactionHistory::transaction(int index, std::function<void (TransactionInfo &)> callback)

@ -5,8 +5,6 @@
#include "libwalletqt/WalletManager.h"
#include "Transfer.h"
#include "Ring.h"
#include <QDateTime>
#include <QDebug>
TransactionInfo::Direction TransactionInfo::direction() const
{

@ -2,7 +2,6 @@
// Copyright (c) 2014-2021, The Monero Project.
#include "UnsignedTransaction.h"
#include <QVector>
#include <QDebug>
UnsignedTransaction::Status UnsignedTransaction::status() const

@ -3,12 +3,6 @@
#include "Wallet.h"
#include <chrono>
#include <stdexcept>
#include <thread>
#include "PendingTransaction.h"
#include "UnsignedTransaction.h"
#include "TransactionHistory.h"
#include "AddressBook.h"
#include "Subaddress.h"
@ -20,17 +14,6 @@
#include "model/SubaddressModel.h"
#include "model/SubaddressAccountModel.h"
#include "model/CoinsModel.h"
#include "wallet/api/wallet2_api.h"
#include <QFile>
#include <QDir>
#include <QDebug>
#include <QUrl>
#include <QTimer>
#include <QtConcurrent/QtConcurrent>
#include <QList>
#include <QVector>
#include <QMutexLocker>
#include "utils/ScopeGuard.h"

@ -3,15 +3,6 @@
#include "libwalletqt/WalletManager.h"
#include "Wallet.h"
#include "wallet/api/wallet2_api.h"
#include <QFile>
#include <QDir>
#include <QDebug>
#include <QUrl>
#include <QtConcurrent/QtConcurrent>
#include <QMutex>
#include <QMutexLocker>
#include <QString>
//#include "qt/updater.h"
#include "utils/ScopeGuard.h"

@ -9,10 +9,6 @@
#include "config-feather.h"
#include "mainwindow.h"
#include "cli.h"
#include "utils/utils.h"
#include "appcontext.h"
#include <QtPlugin>
#if defined(Q_OS_WIN)
#include <windows.h>

@ -7,11 +7,8 @@
#include <QCoreApplication>
#include <QSystemTrayIcon>
#include <QFileDialog>
#include <QInputDialog>
#include "mainwindow.h"
#include "widgets/ccswidget.h"
#include "widgets/redditwidget.h"
#include "dialog/txconfdialog.h"
#include "dialog/txconfadvdialog.h"
#include "dialog/debuginfodialog.h"
@ -22,23 +19,11 @@
#include "dialog/tximportdialog.h"
#include "dialog/passworddialog.h"
#include "dialog/balancedialog.h"
#include "utils/utils.h"
#include "utils/config.h"
#include "utils/daemonrpc.h"
#include "components.h"
#include "calcwindow.h"
#include "ui_mainwindow.h"
#include "globals.h"
// libwalletqt
#include "libwalletqt/WalletManager.h"
#include "Wallet.h"
#include "libwalletqt/TransactionHistory.h"
#include "libwalletqt/SubaddressAccount.h"
#include "libwalletqt/AddressBook.h"
#include "model/SubaddressAccountModel.h"
#include "model/SubaddressModel.h"
#include "utils/networktype.h"
MainWindow * MainWindow::pMainWindow = nullptr;

@ -12,6 +12,7 @@
#include <QSystemTrayIcon>
#include <QScreen>
#include <QtWidgets/QMenu>
#include <utility>
#include <model/SubaddressModel.h>
#include <model/SubaddressProxyModel.h>
#include <model/TransactionHistoryModel.h>
@ -43,8 +44,8 @@ namespace Ui {
}
struct ToggleTab {
ToggleTab(QWidget *tab, const QString &name, const QString &description, QAction *menuAction, Config::ConfigKey configKey) :
tab(tab), key(name), name(description), menuAction(menuAction), configKey(configKey){}
ToggleTab(QWidget *tab, QString name, QString description, QAction *menuAction, Config::ConfigKey configKey) :
tab(tab), key(std::move(name)), name(std::move(description)), menuAction(menuAction), configKey(configKey){}
QWidget *tab;
QString key;
QString name;

@ -5,12 +5,6 @@
#include "AddressBook.h"
#include "ModelUtils.h"
#include "utils/utils.h"
#include <wallet/api/wallet2_api.h>
#include <QDebug>
#include <QFileDialog>
#include <QDir>
#include <QFontDatabase>
AddressBookModel::AddressBookModel(QObject *parent, AddressBook *addressBook)
: QAbstractTableModel(parent),

@ -4,14 +4,10 @@
#include "CoinsModel.h"
#include "CoinsInfo.h"
#include "Coins.h"
#include <wallet/api/wallet2_api.h>
#include "ModelUtils.h"
#include "globals.h"
#include <QDebug>
#include <QHash>
#include <QBrush>
#include <QColor>
#include <QFont>
CoinsModel::CoinsModel(QObject *parent, Coins *coins)

@ -4,7 +4,6 @@
#include "ModelUtils.h"
#include <QDebug>
#include <QStringList>
#include <QClipboard>
#include <QApplication>
#include <QFont>

@ -3,7 +3,6 @@
#include "NodeModel.h"
#include <utils/nodes.h>
#include "appcontext.h"
NodeModel::NodeModel(int nodeSource, QObject *parent)
: QAbstractTableModel(parent)

@ -3,10 +3,8 @@
#include "SubaddressAccountModel.h"
#include "SubaddressAccount.h"
#include <wallet/api/wallet2_api.h>
#include <QDebug>
#include <QHash>
SubaddressAccountModel::SubaddressAccountModel(QObject *parent, SubaddressAccount *subaddressAccount)
: QAbstractListModel(parent), m_subaddressAccount(subaddressAccount)

@ -4,9 +4,7 @@
#include "SubaddressModel.h"
#include "Subaddress.h"
#include "ModelUtils.h"
#include <wallet/api/wallet2_api.h>
#include <QHash>
#include <QPoint>
#include <QColor>
#include <QBrush>

@ -6,10 +6,6 @@
#include "TransactionInfo.h"
#include "globals.h"
#include <QDateTime>
#include <QDebug>
#include <QIcon>
TransactionHistoryModel::TransactionHistoryModel(QObject *parent)
: QAbstractTableModel(parent),
m_transactionHistory(nullptr)

@ -35,7 +35,6 @@ public:
void setTransactionHistory(TransactionHistory * th);
TransactionHistory * transactionHistory() const;
QString preferredFiatSign = "$";
QString preferredFiatSymbol = "USD";
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;

@ -5,7 +5,6 @@
#include "TransactionHistoryModel.h"
#include "libwalletqt/TransactionInfo.h"
#include <QSet>
TransactionHistoryProxyModel::TransactionHistoryProxyModel(Wallet *wallet, QObject *parent)
: QSortFilterProxyModel(parent),

@ -28,17 +28,13 @@
#include "openpgp.h"
#include <algorithm>
#include <locale>
#include <vector>
#include <string_coding.h>
#include "hash.h"
#include "mpi.h"
#include "packet_stream.h"
#include "s_expression.h"
#include "serialization.h"
namespace openpgp
{

@ -21,15 +21,9 @@
#include "QrCode_p.h"
#include <QBrush>
#include <QByteArray>
#include <QIODevice>
#include <QImage>
#include <QPainter>
#include <QPen>
#include <QString>
#include <QSvgGenerator>
#include <QVariant>
#include <QPixmap>
#include <QDebug>

@ -3,12 +3,10 @@
#include "ui_receivewidget.h"
#include "receivewidget.h"
#include "qrcode/QrCode.h"
#include "model/ModelUtils.h"
#include "dialog/qrcodedialog.h"
#include <QMenu>
#include <QClipboard>
ReceiveWidget::ReceiveWidget(QWidget *parent) :
QWidget(parent),

@ -3,7 +3,6 @@
#include <QMessageBox>
#include "sendwidget.h"
#include "widgets/ccswidget.h"
#include "mainwindow.h"
#include "ui_sendwidget.h"
@ -150,7 +149,7 @@ void SendWidget::updateConversionLabel() {
auto preferredFiatCurrency = config()->get(Config::preferredFiatCurrency).toString();
double conversionAmount = AppContext::prices->convert("XMR", preferredFiatCurrency, this->amount());
return QString("~%1 %2").arg(QString::number(conversionAmount, 'f', 2), preferredFiatCurrency);
};
}
}();
ui->label_conversionAmount->setText(conversionAmountStr);

@ -3,8 +3,6 @@
#include "settings.h"
#include "ui_settings.h"
#include "appcontext.h"
#include "utils/config.h"
#include "mainwindow.h"
#include <QFileDialog>

@ -1,8 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <QtCore>
#include <QProcess>
#include "utils/childproc.h"
ChildProcess::ChildProcess(QObject* parent) {}

@ -4,7 +4,6 @@
#ifndef FEATHER_FPROCESS_H
#define FEATHER_FPROCESS_H
#include <QtCore>
#include <QProcess>
#if defined(HAVE_SYS_PRCTL_H) && defined(Q_OS_UNIX)

@ -7,10 +7,6 @@
#include "utils/utils.h"
#include "utils/tails.h"
#include <QCoreApplication>
#include <QDir>
#include <QStandardPaths>
#define QS QStringLiteral
struct ConfigDirective

@ -3,8 +3,6 @@
#include "daemonrpc.h"
#include <utility>
DaemonRpc::DaemonRpc(QObject *parent, UtilsNetworking *network, QString daemonAddress)
: QObject(parent)
, m_network(network)

@ -7,14 +7,8 @@
#include <QDebug>
#include <QUrl>
#include <QtConcurrent/QtConcurrent>
#include <QMutex>
#include <QString>
#include "appcontext.h"
#include "utils/config.h"
#include "utils/networktype.h"
#include "utils/utils.h"
#include "keysfiles.h"
using namespace std::chrono;

@ -7,7 +7,6 @@
#include "libwalletqt/WalletManager.h"
#include "utils/networktype.h"
#include "utils/utils.h"
#include <QtCore>
class WalletKeysFiles
{

@ -1,8 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <QtCore>
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>

@ -4,16 +4,13 @@
#ifndef FEATHER_NETWORKING_H
#define FEATHER_NETWORKING_H
#include <QtCore>
#include <QRegExp>
#include <QApplication>
#include <QtNetwork>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "utils/utils.h"
static QStringList randomHTTPAgents;
class CCSEntry;
class UtilsNetworking : public QObject

@ -1,7 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <QtCore>
#include <QObject>
#include <QNetworkAccessManager>

@ -4,7 +4,6 @@
#ifndef FEATHER_NODES_H
#define FEATHER_NODES_H
#include <QtCore>
#include <QTimer>
#include <QRegExp>
#include <QApplication>

@ -3,7 +3,6 @@
#include <QStandardPaths>
#include <QScreen>
#include <QObject>
#include <QDesktopWidget>
#include "utils/prices.h"

@ -3,10 +3,6 @@
#include "scheduler.h"
#include <mutex>
#include <QThreadPool>
FutureScheduler::FutureScheduler(QObject *parent)
: QObject(parent), Alive(0), Stopping(false)
{

@ -4,7 +4,6 @@
#ifndef FEATHER_SEEDS_H
#define FEATHER_SEEDS_H
#include <QtCore>
#include <cstdio>
#include <cstdlib>
#include <sstream>
@ -16,7 +15,6 @@
#include "libwalletqt/Wallet.h"
#include "utils/utils.h"
struct RestoreHeightLookup {
NetworkType::Type type;
QMap<int, int> data;

@ -3,9 +3,6 @@
#include <QRegExp>
#include <QMessageBox>
#include <QPixmap>
#include <QTranslator>
#include <QCheckBox>
#include "tails.h"
#include "utils.h"

@ -16,7 +16,6 @@ public:
static QString version();
static void showDataPersistenceDisabledWarning();
static void askPersistence();
static void persistXdgMime(const QString& filePath, const QString& data);
static bool usePersistence;

@ -54,8 +54,6 @@
#include <QAbstractItemView>
#include <QtDebug>
#include <QApplication>
#include <QModelIndex>
#include <QAbstractItemModel>
#include <QScrollBar>

@ -1,10 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <QtCore>
#include <QScreen>
#include <QDesktopWidget>
#include <QProcess>
#include <QDesktopServices>
#include "utils/utils.h"
#include "utils/tor.h"
@ -217,48 +215,6 @@ bool Tor::unpackBins() {
return true;
}
networkPeer Tor::getPeerFromConfig(const QString &path) {
// parse Tor bind addr from given Tor config
QRegularExpression re("^SocksPort ([\\d|.|:]+)");
networkPeer peer;
peer.host = "127.0.0.1";
peer.port = 9050;
if(!Utils::fileExists(path)) {
peer.active = Utils::portOpen(peer.host, peer.port);
return peer;
}
for(const auto &line: Utils::fileOpen(path).split('\n')) {
QRegularExpressionMatch match = re.match(line);
if(!match.hasMatch())
continue;
QString match_group = match.captured(1);
int host_idx = match_group.indexOf(':');
if(host_idx >= 1){
peer.host = match_group.mid(0, host_idx);
QString port = match_group.mid(host_idx + 1);
if(!Utils::isDigit(port))
continue;
peer.port = (quint16)port.toInt();
qDebug() << "Parsed port from local Tor config";
break;
}
if(Utils::isDigit(match_group)) {
peer.port = (quint16)match_group.toInt();
qDebug() << "Parsed port from local Tor config";
break;
}
}
peer.active = Utils::portOpen(peer.host, peer.port);
return peer;
}
QString Tor::getVersion() {
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);

@ -7,11 +7,8 @@
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <QtCore>
#include <QRegExp>
#include <QtNetwork>
#include <QApplication>
#include <QMainWindow>
#include "utils/childproc.h"
class Tor : public QObject
@ -25,7 +22,6 @@ public:
void stop();
bool unpackBins();
QString getVersion();
networkPeer getPeerFromConfig(const QString &path);
bool torConnected = false;
bool localTor = false;

@ -1,10 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <QtCore>
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <iomanip>
#include "txfiathistory.h"

@ -4,7 +4,6 @@
#ifndef FEATHER_TXFIATHISTORY_H
#define FEATHER_TXFIATHISTORY_H
class TxFiatHistory : public QObject {
Q_OBJECT

@ -1,23 +1,13 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <QtCore>
#include <QtGlobal>
#include <QObject>
#include <QScreen>
#include <QMessageBox>
#include <QtNetwork>
#include <QTcpSocket>
#include <QClipboard>
#include <QDesktopWidget>
#include <QProcess>
#include <QCompleter>
#include <QDesktopServices>
#include <QApplication>
#include <QMainWindow>
#include <QTextStream>
#include <QtWidgets/QStyle>
#include <QVector>
#include "utils.h"
#include "utils/config.h"
@ -214,69 +204,6 @@ QByteArray Utils::readSocket(QTcpSocket &socket, int buffer_size) {
return data;
}
bool Utils::testSocks5(const QString &host, quint16 port){
// synchronous socks5 tester
QByteArray data;
QTcpSocket socket;
socket.connectToHost(host, port);
if (!socket.waitForConnected(1000)) {
qDebug() << QString("could not connect to %1 %2")
.arg(host).arg(port);
socket.close();
return false;
}
// latest & greatest
socket.write(QByteArray("\x05\x02", 2));
socket.flush();
// no auth pl0x
socket.write(QByteArray("\x00\x01", 2));
socket.flush();
// cool story
if(Utils::readSocket(socket, 2).isEmpty()){
qDebug() << "socks response timeout";
socket.close();
return false;
}
// pls sir
socket.write(QByteArray("\x05\x01\x00\x03", 4));
// here we go!!
socket.write(QByteArray("\x16", 1)); // len
socket.write(QByteArray("kebjllr47c2ouoly.onion"));
socket.write(QByteArray("\x00\x50", 2)); // port
socket.flush();
// fingers crossed
auto result = Utils::readSocket(socket, 10);
qDebug() << result;
if(result.length() != 10 || result.at(1) != 0) {
qDebug() << "bad socks response";
socket.close();
return false;
}
// can haz?
QByteArray http("GET /api/v1/ping HTTP/1.1\r\nHost: kebjllr47c2ouoly.onion\r\nConnection: close\r\n\r\n");
socket.write(http);
auto resp = Utils::readSocket(socket, 555);
QRegularExpression re(R"(^HTTP\/\d.\d 200 OK)");
QRegularExpressionMatch match = re.match(resp);
if(match.hasMatch()){
socket.close();
return true;
}
qDebug() << resp;
socket.close();
return false;
}
void Utils::externalLinkWarning(QWidget *parent, const QString &url){
if(!config()->get(Config::warnOnExternalLink).toBool()) {
QDesktopServices::openUrl(QUrl(url));

@ -6,7 +6,6 @@
#include <cstdio>
#include <cstdlib>
#include <QtCore>
#include <QRegExp>
#include <QStandardItemModel>
#include <QtNetwork>
@ -80,7 +79,7 @@ public:
static bool dirExists(const QString &path);
static QString barrayToString(const QByteArray &data);
static QByteArray readSocket(QTcpSocket &socket, int buffer_size);
static bool testSocks5(const QString &host, quint16 port);
static QStandardItem *qStandardItem(const QString &text);
static QStandardItem *qStandardItem(const QString &text, QFont &font);
static void copyToClipboard(const QString &string);

@ -3,14 +3,11 @@
#include <QObject>
#include <QNetworkAccessManager>
#include <QStandardPaths>
#include <QScreen>
#include <QDesktopWidget>
#include <QtCore>
#include "wsclient.h"