refactor: remove appcontext, cleanup Wallet

This commit is contained in:
tobtoht
2023-03-01 03:05:56 +01:00
parent b057f750a5
commit 402bea3fd6
82 changed files with 1626 additions and 2340 deletions
+15 -13
View File
@@ -7,23 +7,25 @@
#include <QMenu>
#include "libwalletqt/SubaddressAccount.h"
#include "libwalletqt/WalletManager.h"
#include "model/ModelUtils.h"
#include "utils/Icons.h"
#include "utils/Utils.h"
AccountSwitcherDialog::AccountSwitcherDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
AccountSwitcherDialog::AccountSwitcherDialog(Wallet *wallet, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::AccountSwitcherDialog)
, m_ctx(std::move(ctx))
, m_model(m_ctx->wallet->subaddressAccountModel())
, m_wallet(wallet)
, m_model(wallet->subaddressAccountModel())
, m_proxyModel(new SubaddressAccountProxyModel(this))
{
ui->setupUi(this);
m_ctx->wallet->subaddressAccount()->refresh();
m_wallet->subaddressAccount()->refresh();
m_proxyModel->setSourceModel(m_model);
ui->label_totalBalance->setFont(ModelUtils::getMonospaceFont());
ui->label_totalBalance->setText(WalletManager::displayAmount(m_ctx->wallet->balanceAll()));
ui->label_totalBalance->setText(WalletManager::displayAmount(m_wallet->balanceAll()));
this->setWindowModality(Qt::WindowModal);
@@ -43,12 +45,12 @@ AccountSwitcherDialog::AccountSwitcherDialog(QSharedPointer<AppContext> ctx, QWi
connect(ui->accounts, &QTreeView::customContextMenuRequested, this, &AccountSwitcherDialog::showContextMenu);
connect(ui->btn_newAccount, &QPushButton::clicked, [this]{
m_ctx->wallet->addSubaddressAccount("New account");
m_ctx->wallet->subaddressAccount()->refresh();
m_wallet->addSubaddressAccount("New account");
m_wallet->subaddressAccount()->refresh();
});
connect(m_ctx->wallet, &Wallet::currentSubaddressAccountChanged, this, &AccountSwitcherDialog::updateSelection);
connect(m_ctx->wallet->subaddressAccount(), &SubaddressAccount::refreshFinished, this, &AccountSwitcherDialog::updateSelection);
connect(m_wallet, &Wallet::currentSubaddressAccountChanged, this, &AccountSwitcherDialog::updateSelection);
connect(m_wallet->subaddressAccount(), &SubaddressAccount::refreshFinished, this, &AccountSwitcherDialog::updateSelection);
this->updateSelection();
}
@@ -59,7 +61,7 @@ void AccountSwitcherDialog::switchAccount() {
return;
}
m_ctx->wallet->switchSubaddressAccount(row->getRowId());
m_wallet->switchSubaddressAccount(row->getRowId());
}
void AccountSwitcherDialog::copyLabel() {
@@ -81,13 +83,13 @@ void AccountSwitcherDialog::copyBalance() {
}
void AccountSwitcherDialog::editLabel() {
QModelIndex index = ui->accounts->currentIndex().siblingAtColumn(m_ctx->wallet->subaddressAccountModel()->Column::Label);
QModelIndex index = ui->accounts->currentIndex().siblingAtColumn(m_wallet->subaddressAccountModel()->Column::Label);
ui->accounts->setCurrentIndex(index);
ui->accounts->edit(index);
}
void AccountSwitcherDialog::updateSelection() {
QModelIndex index = m_model->index(m_ctx->wallet->currentSubaddressAccount(), 0);
QModelIndex index = m_model->index(m_wallet->currentSubaddressAccount(), 0);
ui->accounts->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
}
@@ -108,7 +110,7 @@ void AccountSwitcherDialog::showContextMenu(const QPoint &point) {
Monero::SubaddressAccountRow* AccountSwitcherDialog::currentEntry() {
QModelIndex index = m_proxyModel->mapToSource(ui->accounts->currentIndex());
return m_ctx->wallet->subaddressAccountModel()->entryFromIndex(index);
return m_wallet->subaddressAccountModel()->entryFromIndex(index);
}
AccountSwitcherDialog::~AccountSwitcherDialog() = default;
+3 -3
View File
@@ -6,7 +6,7 @@
#include <QDialog>
#include "appcontext.h"
#include "libwalletqt/Wallet.h"
#include "components.h"
#include "model/SubaddressAccountModel.h"
@@ -19,7 +19,7 @@ class AccountSwitcherDialog : public WindowModalDialog
Q_OBJECT
public:
explicit AccountSwitcherDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
explicit AccountSwitcherDialog(Wallet *wallet, QWidget *parent = nullptr);
~AccountSwitcherDialog() override;
private slots:
@@ -35,7 +35,7 @@ private:
Monero::SubaddressAccountRow* currentEntry();
QScopedPointer<Ui::AccountSwitcherDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
SubaddressAccountModel *m_model;
SubaddressAccountProxyModel *m_proxyModel;
};
+21 -18
View File
@@ -5,15 +5,18 @@
#include "ui_DebugInfoDialog.h"
#include "config-feather.h"
#include "utils/AppData.h"
#include "utils/os/tails.h"
#include "utils/os/whonix.h"
#include "utils/TorManager.h"
#include "utils/WebsocketClient.h"
#include "utils/WebsocketNotifier.h"
DebugInfoDialog::DebugInfoDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
DebugInfoDialog::DebugInfoDialog(Wallet *wallet, Nodes *nodes, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::DebugInfoDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
, m_nodes(nodes)
{
ui->setupUi(this);
@@ -47,16 +50,16 @@ void DebugInfoDialog::updateInfo() {
ui->label_featherVersion->setText(QString("%1-%2").arg(FEATHER_VERSION, FEATHER_COMMIT));
ui->label_walletHeight->setText(QString::number(m_ctx->wallet->blockChainHeight()));
ui->label_daemonHeight->setText(QString::number(m_ctx->wallet->daemonBlockChainHeight()));
ui->label_targetHeight->setText(QString::number(m_ctx->wallet->daemonBlockChainTargetHeight()));
QDateTime restoreDate = appData()->restoreHeights[constants::networkType]->heightToDate(m_ctx->wallet->getWalletCreationHeight());
ui->label_restoreHeight->setText(QString("%1 (%2)").arg(QString::number(m_ctx->wallet->getWalletCreationHeight()), restoreDate.toString("yyyy-MM-dd")));
ui->label_synchronized->setText(m_ctx->wallet->isSynchronized() ? "True" : "False");
ui->label_walletHeight->setText(QString::number(m_wallet->blockChainHeight()));
ui->label_daemonHeight->setText(QString::number(m_wallet->daemonBlockChainHeight()));
ui->label_targetHeight->setText(QString::number(m_wallet->daemonBlockChainTargetHeight()));
QDateTime restoreDate = appData()->restoreHeights[constants::networkType]->heightToDate(m_wallet->getWalletCreationHeight());
ui->label_restoreHeight->setText(QString("%1 (%2)").arg(QString::number(m_wallet->getWalletCreationHeight()), restoreDate.toString("yyyy-MM-dd")));
ui->label_synchronized->setText(m_wallet->isSynchronized() ? "True" : "False");
auto node = m_ctx->nodes->connection();
auto node = m_nodes->connection();
ui->label_remoteNode->setText(node.toAddress());
ui->label_walletStatus->setText(this->statusToString(m_ctx->wallet->connectionStatus()));
ui->label_walletStatus->setText(this->statusToString(m_wallet->connectionStatus()));
QString websocketStatus = Utils::QtEnumToString(websocketNotifier()->websocketClient.webSocket.state()).remove("State");
if (config()->get(Config::disableWebsocket).toBool()) {
websocketStatus = "Disabled";
@@ -66,16 +69,16 @@ void DebugInfoDialog::updateInfo() {
ui->label_torLevel->setText(config()->get(Config::torPrivacyLevel).toString());
QString seedType = [this](){
if (m_ctx->wallet->isHwBacked())
if (m_wallet->isHwBacked())
return QString("Hardware");
return QString("%1 word").arg(m_ctx->wallet->seedLength());
return QString("%1 word").arg(m_wallet->seedLength());
}();
QString deviceType = [this](){
if (m_ctx->wallet->isHwBacked()) {
if (m_ctx->wallet->isLedger())
if (m_wallet->isHwBacked()) {
if (m_wallet->isLedger())
return "Ledger";
else if (m_ctx->wallet->isTrezor())
else if (m_wallet->isTrezor())
return "Trezor";
else
return "Unknown";
@@ -85,15 +88,15 @@ void DebugInfoDialog::updateInfo() {
}
}();
QString networkType = Utils::QtEnumToString(m_ctx->wallet->nettype());
QString networkType = Utils::QtEnumToString(m_wallet->nettype());
if (config()->get(Config::offlineMode).toBool()) {
networkType += " (offline)";
}
ui->label_netType->setText(networkType);
ui->label_seedType->setText(seedType);
ui->label_deviceType->setText(deviceType);
ui->label_viewOnly->setText(m_ctx->wallet->viewOnly() ? "True" : "False");
ui->label_primaryOnly->setText(m_ctx->wallet->balance(0) == m_ctx->wallet->balanceAll() ? "True" : "False");
ui->label_viewOnly->setText(m_wallet->viewOnly() ? "True" : "False");
ui->label_primaryOnly->setText(m_wallet->balance(0) == m_wallet->balanceAll() ? "True" : "False");
QString os = QSysInfo::prettyProductName();
if (TailsOS::detect()) {
+4 -3
View File
@@ -6,9 +6,9 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/Wallet.h"
#include "utils/nodes.h"
namespace Ui {
class DebugInfoDialog;
@@ -19,7 +19,7 @@ class DebugInfoDialog : public WindowModalDialog
Q_OBJECT
public:
explicit DebugInfoDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
explicit DebugInfoDialog(Wallet *wallet, Nodes *nodes, QWidget *parent = nullptr);
~DebugInfoDialog() override;
private:
@@ -28,7 +28,8 @@ private:
void updateInfo();
QScopedPointer<Ui::DebugInfoDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
Nodes *m_nodes;
QTimer m_updateTimer;
};
+7 -7
View File
@@ -4,7 +4,7 @@
#include "KeysDialog.h"
#include "ui_KeysDialog.h"
KeysDialog::KeysDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
KeysDialog::KeysDialog(Wallet *wallet, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::KeysDialog)
{
@@ -12,12 +12,12 @@ KeysDialog::KeysDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
QString unavailable = "Unavailable: Key is stored on hardware device";
ui->label_restoreHeight->setText(QString::number(ctx->wallet->getWalletCreationHeight()));
ui->label_primaryAddress->setText(ctx->wallet->address(0, 0));
ui->label_secretSpendKey->setText(ctx->wallet->isHwBacked() ? unavailable : ctx->wallet->getSecretSpendKey());
ui->label_secretViewKey->setText(ctx->wallet->getSecretViewKey());
ui->label_publicSpendKey->setText(ctx->wallet->getPublicSpendKey());
ui->label_publicViewKey->setText(ctx->wallet->getPublicViewKey());
ui->label_restoreHeight->setText(QString::number(wallet->getWalletCreationHeight()));
ui->label_primaryAddress->setText(wallet->address(0, 0));
ui->label_secretSpendKey->setText(wallet->isHwBacked() ? unavailable : wallet->getSecretSpendKey());
ui->label_secretViewKey->setText(wallet->getSecretViewKey());
ui->label_publicSpendKey->setText(wallet->getPublicSpendKey());
ui->label_publicViewKey->setText(wallet->getPublicViewKey());
this->adjustSize();
}
+2 -2
View File
@@ -6,8 +6,8 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class KeysDialog;
@@ -18,7 +18,7 @@ class KeysDialog : public WindowModalDialog
Q_OBJECT
public:
explicit KeysDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
explicit KeysDialog(Wallet *wallet, QWidget *parent = nullptr);
~KeysDialog() override;
private:
+4 -3
View File
@@ -10,11 +10,12 @@
#include <QRegularExpressionValidator>
#include "WalletManager.h"
#include "utils/Utils.h"
PaymentRequestDialog::PaymentRequestDialog(QWidget *parent, QSharedPointer<AppContext> ctx, QString address)
PaymentRequestDialog::PaymentRequestDialog(QWidget *parent, Wallet *wallet, QString address)
: WindowModalDialog(parent)
, ui(new Ui::PaymentRequestDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
, m_address(std::move(address))
{
ui->setupUi(this);
@@ -45,7 +46,7 @@ void PaymentRequestDialog::updatePaymentRequest() {
QString recipient = ui->line_recipient->text();
quint64 amount = WalletManager::amountFromString(ui->line_amountXMR->text());
QString uri = m_ctx->wallet->make_uri(m_address, amount, description, recipient);
QString uri = m_wallet->make_uri(m_address, amount, description, recipient);
ui->line_paymentRequestUri->setText(uri);
ui->line_paymentRequestUri->setCursorPosition(0);
+3 -3
View File
@@ -6,8 +6,8 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/Wallet.h"
#include "qrcode/QrCode.h"
namespace Ui {
@@ -19,7 +19,7 @@ class PaymentRequestDialog : public WindowModalDialog
Q_OBJECT
public:
explicit PaymentRequestDialog(QWidget *parent, QSharedPointer<AppContext> ctx, QString address);
explicit PaymentRequestDialog(QWidget *parent, Wallet *wallet, QString address);
~PaymentRequestDialog() override;
private slots:
@@ -30,7 +30,7 @@ private slots:
private:
QScopedPointer<Ui::PaymentRequestDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
QString m_address;
QrCode *m_qrCode;
};
+9 -9
View File
@@ -6,26 +6,26 @@
#include "constants.h"
SeedDialog::SeedDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
SeedDialog::SeedDialog(Wallet *wallet, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::SeedDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
{
ui->setupUi(this);
ui->label_seedIcon->setPixmap(QPixmap(":/assets/images/seed.png").scaledToWidth(64, Qt::SmoothTransformation));
ui->label_restoreHeight->setText(QString::number(m_ctx->wallet->getWalletCreationHeight()));
ui->label_restoreHeight->setText(QString::number(m_wallet->getWalletCreationHeight()));
if (m_ctx->wallet->getSeedLanguage().isEmpty()) {
if (m_wallet->getSeedLanguage().isEmpty()) {
qDebug() << "No seed language set, using default";
m_ctx->wallet->setSeedLanguage(constants::seedLanguage);
m_wallet->setSeedLanguage(constants::seedLanguage);
}
QString seedOffset = m_ctx->wallet->getCacheAttribute("feather.seedoffset");
QString seed = m_ctx->wallet->getCacheAttribute("feather.seed");
auto seedLength = m_ctx->wallet->seedLength();
QString seedOffset = m_wallet->getCacheAttribute("feather.seedoffset");
QString seed = m_wallet->getCacheAttribute("feather.seed");
auto seedLength = m_wallet->seedLength();
QString seed_25_words = m_ctx->wallet->getSeed(seedOffset);
QString seed_25_words = m_wallet->getSeed(seedOffset);
if (seedLength >= 24) {
ui->check_toggleSeedType->hide();
+3 -3
View File
@@ -6,8 +6,8 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class SeedDialog;
@@ -18,14 +18,14 @@ class SeedDialog : public WindowModalDialog
Q_OBJECT
public:
explicit SeedDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
explicit SeedDialog(Wallet *wallet, QWidget *parent = nullptr);
~SeedDialog() override;
private:
void setSeed(const QString &seed);
QScopedPointer<Ui::SeedDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
};
+4 -4
View File
@@ -8,14 +8,14 @@
#include "utils/NetworkManager.h"
TxBroadcastDialog::TxBroadcastDialog(QWidget *parent, QSharedPointer<AppContext> ctx, const QString &transactionHex)
TxBroadcastDialog::TxBroadcastDialog(QWidget *parent, Nodes *nodes, const QString &transactionHex)
: WindowModalDialog(parent)
, ui(new Ui::TxBroadcastDialog)
, m_ctx(std::move(ctx))
, m_nodes(nodes)
{
ui->setupUi(this);
auto node = m_ctx->nodes->connection();
auto node = m_nodes->connection();
m_rpc = new DaemonRpc(this, node.toAddress());
connect(ui->btn_Broadcast, &QPushButton::clicked, this, &TxBroadcastDialog::broadcastTx);
@@ -33,7 +33,7 @@ TxBroadcastDialog::TxBroadcastDialog(QWidget *parent, QSharedPointer<AppContext>
void TxBroadcastDialog::broadcastTx() {
QString tx = ui->transaction->toPlainText();
FeatherNode node = ui->radio_useCustom->isChecked() ? FeatherNode(ui->customNode->text()) : m_ctx->nodes->connection();
FeatherNode node = ui->radio_useCustom->isChecked() ? FeatherNode(ui->customNode->text()) : m_nodes->connection();
m_rpc->setDaemonAddress(node.toURL());
m_rpc->sendRawTransaction(tx);
+3 -3
View File
@@ -6,9 +6,9 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "utils/daemonrpc.h"
#include "utils/nodes.h"
namespace Ui {
class TxBroadcastDialog;
@@ -19,7 +19,7 @@ class TxBroadcastDialog : public WindowModalDialog
Q_OBJECT
public:
explicit TxBroadcastDialog(QWidget *parent, QSharedPointer<AppContext> ctx, const QString &transactionHex = "");
explicit TxBroadcastDialog(QWidget *parent, Nodes *nodes, const QString &transactionHex = "");
~TxBroadcastDialog() override;
private slots:
@@ -28,7 +28,7 @@ private slots:
private:
QScopedPointer<Ui::TxBroadcastDialog> ui;
QSharedPointer<AppContext> m_ctx;
Nodes *m_nodes;
DaemonRpc *m_rpc;
};
+12 -8
View File
@@ -11,13 +11,17 @@
#include "dialog/QrCodeDialog.h"
#include "libwalletqt/Input.h"
#include "libwalletqt/Transfer.h"
#include "libwalletqt/WalletManager.h"
#include "model/ModelUtils.h"
#include "qrcode/QrCode.h"
#include "utils/AppData.h"
#include "utils/config.h"
#include "utils/Utils.h"
TxConfAdvDialog::TxConfAdvDialog(QSharedPointer<AppContext> ctx, const QString &description, QWidget *parent)
TxConfAdvDialog::TxConfAdvDialog(Wallet *wallet, const QString &description, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::TxConfAdvDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
, m_exportUnsignedMenu(new QMenu(this))
, m_exportSignedMenu(new QMenu(this))
, m_exportTxKeyMenu(new QMenu(this))
@@ -65,7 +69,7 @@ void TxConfAdvDialog::setTransaction(PendingTransaction *tx, bool isSigned) {
PendingTransactionInfo *ptx = m_tx->transaction(0); //Todo: support split transactions
// TODO: implement hasTxKey()
if (!m_ctx->wallet->isHwBacked() && m_tx->transaction(0)->txKey() == "0100000000000000000000000000000000000000000000000000000000000000") {
if (!m_wallet->isHwBacked() && m_tx->transaction(0)->txKey() == "0100000000000000000000000000000000000000000000000000000000000000") {
ui->btn_exportTxKey->hide();
}
@@ -148,7 +152,7 @@ void TxConfAdvDialog::setupConstructionData(ConstructionInfo *ci) {
for (const auto& o: outputs) {
auto address = o->address();
auto amount = WalletManager::displayAmount(o->amount());
auto index = m_ctx->wallet->subaddressIndex(address);
auto index = m_wallet->subaddressIndex(address);
cursor.insertText(address, Utils::addressTextFormat(index, o->amount()));
cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
cursor.insertBlock();
@@ -205,7 +209,7 @@ void TxConfAdvDialog::signedCopy() {
}
void TxConfAdvDialog::txKeyCopy() {
if (m_ctx->wallet->isHwBacked()) {
if (m_wallet->isHwBacked()) {
QMessageBox::warning(this, "Unable to get tx private key", "Unable to get tx secret key: wallet is backed by hardware device");
return;
}
@@ -218,15 +222,15 @@ void TxConfAdvDialog::signedQrCode() {
void TxConfAdvDialog::broadcastTransaction() {
if (m_tx == nullptr) return;
m_ctx->commitTransaction(m_tx, ui->line_description->text());
m_wallet->commitTransaction(m_tx, ui->line_description->text());
QDialog::accept();
}
void TxConfAdvDialog::closeDialog() {
if (m_tx != nullptr)
m_ctx->wallet->disposeTransaction(m_tx);
m_wallet->disposeTransaction(m_tx);
if (m_utx != nullptr)
m_ctx->wallet->disposeTransaction(m_utx);
m_wallet->disposeTransaction(m_utx);
QDialog::reject();
}
+3 -3
View File
@@ -9,9 +9,9 @@
#include <QStandardItemModel>
#include <QTextCharFormat>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/PendingTransaction.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class TxConfAdvDialog;
@@ -22,7 +22,7 @@ class TxConfAdvDialog : public WindowModalDialog
Q_OBJECT
public:
explicit TxConfAdvDialog(QSharedPointer<AppContext> ctx, const QString &description, QWidget *parent = nullptr);
explicit TxConfAdvDialog(Wallet *wallet, const QString &description, QWidget *parent = nullptr);
~TxConfAdvDialog() override;
void setTransaction(PendingTransaction *tx, bool isSigned = true); // #TODO: have libwallet return a UnsignedTransaction, this is just dumb
@@ -46,7 +46,7 @@ private:
void txKeyCopy();
QScopedPointer<Ui::TxConfAdvDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
PendingTransaction *m_tx = nullptr;
UnsignedTransaction *m_utx = nullptr;
QMenu *m_exportUnsignedMenu;
+4 -3
View File
@@ -11,11 +11,12 @@
#include "TxConfAdvDialog.h"
#include "utils/AppData.h"
#include "utils/ColorScheme.h"
#include "utils/config.h"
TxConfDialog::TxConfDialog(QSharedPointer<AppContext> ctx, PendingTransaction *tx, const QString &address, const QString &description, QWidget *parent)
TxConfDialog::TxConfDialog(Wallet *wallet, PendingTransaction *tx, const QString &address, const QString &description, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::TxConfDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
, m_tx(tx)
, m_address(address)
, m_description(description)
@@ -53,7 +54,7 @@ TxConfDialog::TxConfDialog(QSharedPointer<AppContext> ctx, PendingTransaction *t
ui->label_fee->setText(QString("%1 (%2 %3)").arg(amounts[1], amounts_fiat[1], preferredCur));
ui->label_total->setText(QString("%1 (%2 %3)").arg(amounts[2], amounts_fiat[2], preferredCur));
auto subaddressIndex = m_ctx->wallet->subaddressIndex(address);
auto subaddressIndex = m_wallet->subaddressIndex(address);
QString addressExtra;
ui->label_address->setText(ModelUtils::displayAddress(address, 2));
+3 -3
View File
@@ -6,10 +6,10 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/PendingTransaction.h"
#include "libwalletqt/WalletManager.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class TxConfDialog;
@@ -20,7 +20,7 @@ class TxConfDialog : public WindowModalDialog
Q_OBJECT
public:
explicit TxConfDialog(QSharedPointer<AppContext> ctx, PendingTransaction *tx, const QString &address, const QString &description, QWidget *parent = nullptr);
explicit TxConfDialog(Wallet *wallet, PendingTransaction *tx, const QString &address, const QString &description, QWidget *parent = nullptr);
~TxConfDialog() override;
bool showAdvanced = false;
@@ -29,7 +29,7 @@ private:
void setShowAdvanced();
QScopedPointer<Ui::TxConfDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
PendingTransaction *m_tx;
QString m_address;
QString m_description;
+6 -6
View File
@@ -8,10 +8,10 @@
#include "utils/NetworkManager.h"
TxImportDialog::TxImportDialog(QWidget *parent, QSharedPointer<AppContext> ctx)
TxImportDialog::TxImportDialog(QWidget *parent, Wallet *wallet)
: WindowModalDialog(parent)
, ui(new Ui::TxImportDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
{
ui->setupUi(this);
@@ -23,15 +23,15 @@ TxImportDialog::TxImportDialog(QWidget *parent, QSharedPointer<AppContext> ctx)
void TxImportDialog::onImport() {
QString txid = ui->line_txid->text();
if (m_ctx->wallet->haveTransaction(txid)) {
if (m_wallet->haveTransaction(txid)) {
QMessageBox::warning(this, "Warning", "This transaction already exists in the wallet. "
"If you can't find it in your history, "
"check if it belongs to a different account (Wallet -> Account)");
return;
}
if (m_ctx->wallet->importTransaction(txid)) {
if (!m_ctx->wallet->haveTransaction(txid)) {
if (m_wallet->importTransaction(txid)) {
if (!m_wallet->haveTransaction(txid)) {
QMessageBox::warning(this, "Import transaction", "This transaction does not belong to this wallet.");
return;
}
@@ -39,7 +39,7 @@ void TxImportDialog::onImport() {
} else {
QMessageBox::warning(this, "Import transaction", "Transaction import failed.");
}
m_ctx->refreshModels();
m_wallet->refreshModels();
}
TxImportDialog::~TxImportDialog() = default;
+3 -3
View File
@@ -6,9 +6,9 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "utils/daemonrpc.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class TxImportDialog;
@@ -19,7 +19,7 @@ class TxImportDialog : public WindowModalDialog
Q_OBJECT
public:
explicit TxImportDialog(QWidget *parent, QSharedPointer<AppContext> ctx);
explicit TxImportDialog(QWidget *parent, Wallet *wallet);
~TxImportDialog() override;
private slots:
@@ -27,7 +27,7 @@ private slots:
private:
QScopedPointer<Ui::TxImportDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
};
+8 -9
View File
@@ -7,7 +7,6 @@
#include <QMessageBox>
#include <QScrollBar>
#include "appcontext.h"
#include "config.h"
#include "constants.h"
#include "libwalletqt/Coins.h"
@@ -19,12 +18,12 @@
#include "Utils.h"
#include "utils/Icons.h"
TxInfoDialog::TxInfoDialog(QSharedPointer<AppContext> ctx, TransactionInfo *txInfo, QWidget *parent)
TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *parent)
: QDialog(parent)
, ui(new Ui::TxInfoDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
, m_txInfo(txInfo)
, m_txProofDialog(new TxProofDialog(this, m_ctx, txInfo))
, m_txProofDialog(new TxProofDialog(this, wallet, txInfo))
{
ui->setupUi(this);
@@ -39,7 +38,7 @@ TxInfoDialog::TxInfoDialog(QSharedPointer<AppContext> ctx, TransactionInfo *txIn
connect(ui->btn_CopyTxKey, &QPushButton::clicked, this, &TxInfoDialog::copyTxKey);
connect(ui->btn_createTxProof, &QPushButton::clicked, this, &TxInfoDialog::createTxProof);
connect(m_ctx->wallet, &Wallet::newBlock, this, &TxInfoDialog::updateData);
connect(m_wallet, &Wallet::newBlock, this, &TxInfoDialog::updateData);
this->setData(txInfo);
@@ -79,7 +78,7 @@ TxInfoDialog::TxInfoDialog(QSharedPointer<AppContext> ctx, TransactionInfo *txIn
for (const auto& transfer : transfers) {
auto address = transfer->address();
auto amount = WalletManager::displayAmount(transfer->amount());
auto index = m_ctx->wallet->subaddressIndex(address);
auto index = m_wallet->subaddressIndex(address);
cursor.insertText(address, Utils::addressTextFormat(index, transfer->amount()));
cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
cursor.insertBlock();
@@ -151,7 +150,7 @@ void TxInfoDialog::setData(TransactionInfo *tx) {
}
void TxInfoDialog::updateData() {
TransactionInfo *tx = m_ctx->wallet->history()->transaction(m_txid);
TransactionInfo *tx = m_wallet->history()->transaction(m_txid);
if (!tx) return;
this->setData(tx);
}
@@ -161,12 +160,12 @@ void TxInfoDialog::copyTxID() {
}
void TxInfoDialog::copyTxKey() {
if (m_ctx->wallet->isHwBacked()) {
if (m_wallet->isHwBacked()) {
QMessageBox::warning(this, "Unable to get tx private key", "Unable to get tx secret key: wallet is backed by hardware device");
return;
}
m_ctx->wallet->getTxKeyAsync(m_txid, [this](QVariantMap map){
m_wallet->getTxKeyAsync(m_txid, [this](QVariantMap map){
QString txKey = map.value("tx_key").toString();
if (txKey.isEmpty()) {
QMessageBox::warning(this, "Unable to copy transaction key", "Transaction key unknown");
+2 -3
View File
@@ -9,7 +9,6 @@
#include <QTextEdit>
#include <QSvgWidget>
#include "appcontext.h"
#include "dialog/TxProofDialog.h"
namespace Ui {
@@ -21,7 +20,7 @@ class TxInfoDialog : public QDialog
Q_OBJECT
public:
explicit TxInfoDialog(QSharedPointer<AppContext> ctx, TransactionInfo *txInfo, QWidget *parent = nullptr);
explicit TxInfoDialog(Wallet *wallet, TransactionInfo *txInfo, QWidget *parent = nullptr);
~TxInfoDialog() override;
signals:
@@ -37,7 +36,7 @@ private:
void viewOnBlockExplorer();
QScopedPointer<Ui::TxInfoDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
TransactionInfo *m_txInfo;
TxProofDialog *m_txProofDialog;
QString m_txid;
+8 -8
View File
@@ -10,10 +10,10 @@
#include "utils/Icons.h"
#include "utils/Utils.h"
TxProofDialog::TxProofDialog(QWidget *parent, QSharedPointer<AppContext> ctx, TransactionInfo *txInfo)
TxProofDialog::TxProofDialog(QWidget *parent, Wallet *wallet, TransactionInfo *txInfo)
: WindowModalDialog(parent)
, ui(new Ui::TxProofDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
{
ui->setupUi(this);
@@ -26,7 +26,7 @@ TxProofDialog::TxProofDialog(QWidget *parent, QSharedPointer<AppContext> ctx, Tr
}
for (auto const &s: txInfo->subaddrIndex()) {
m_InDestinations.push_back(m_ctx->wallet->address(txInfo->subaddrAccount(), s));
m_InDestinations.push_back(m_wallet->address(txInfo->subaddrAccount(), s));
}
// Due to some logic in core we can't create OutProofs
@@ -57,7 +57,7 @@ TxProofDialog::TxProofDialog(QWidget *parent, QSharedPointer<AppContext> ctx, Tr
void TxProofDialog::getTxKey() {
if (!m_txKey.isEmpty()) return;
m_ctx->wallet->getTxKeyAsync(m_txid, [this](QVariantMap map){
m_wallet->getTxKeyAsync(m_txid, [this](QVariantMap map){
m_txKey = map.value("tx_key").toString();
});
}
@@ -75,7 +75,7 @@ void TxProofDialog::selectSpendProof() {
return;
}
if (m_ctx->wallet->isHwBacked()) {
if (m_wallet->isHwBacked()) {
this->showWarning("SpendProof creation is not supported on this hardware device.");
return;
}
@@ -150,7 +150,7 @@ void TxProofDialog::showWarning(const QString &message) {
void TxProofDialog::getFormattedProof() {
QString message = ui->message->toPlainText();
QString address = ui->combo_address->currentText();
QString nettype = Utils::QtEnumToString(m_ctx->wallet->nettype()).toLower();
QString nettype = Utils::QtEnumToString(m_wallet->nettype()).toLower();
nettype = nettype.replace(0, 1, nettype[0].toUpper()); // Capitalize first letter
TxProof proof = this->getProof();
@@ -231,12 +231,12 @@ TxProof TxProofDialog::getProof() {
TxProof proof = [this, message, address]{
switch (m_mode) {
case Mode::SpendProof: {
return m_ctx->wallet->getSpendProof(m_txid, message);
return m_wallet->getSpendProof(m_txid, message);
}
case Mode::OutProof:
case Mode::InProof:
default: { // Todo: split this into separate functions
return m_ctx->wallet->getTxProof(m_txid, address, message);
return m_wallet->getTxProof(m_txid, address, message);
}
}
}();
+3 -3
View File
@@ -6,9 +6,9 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/TransactionInfo.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class TxProofDialog;
@@ -19,7 +19,7 @@ class TxProofDialog : public WindowModalDialog
Q_OBJECT
public:
explicit TxProofDialog(QWidget *parent, QSharedPointer<AppContext> ctx, TransactionInfo *txid);
explicit TxProofDialog(QWidget *parent, Wallet *wallet, TransactionInfo *txid);
~TxProofDialog() override;
void setTxId(const QString &txid);
void getTxKey();
@@ -45,7 +45,7 @@ private:
void showWarning(const QString &message);
QScopedPointer<Ui::TxProofDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
QStringList m_OutDestinations;
QStringList m_InDestinations;
+9 -7
View File
@@ -8,21 +8,23 @@
#include <QInputDialog>
#include <QMessageBox>
ViewOnlyDialog::ViewOnlyDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
#include "utils/Utils.h"
ViewOnlyDialog::ViewOnlyDialog(Wallet *wallet, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::ViewOnlyDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
{
ui->setupUi(this);
ui->label_restoreHeight->setText(QString::number(m_ctx->wallet->getWalletCreationHeight()));
ui->label_primaryAddress->setText(m_ctx->wallet->address(0, 0));
ui->label_secretViewKey->setText(m_ctx->wallet->getSecretViewKey());
ui->label_restoreHeight->setText(QString::number(m_wallet->getWalletCreationHeight()));
ui->label_primaryAddress->setText(m_wallet->address(0, 0));
ui->label_secretViewKey->setText(m_wallet->getSecretViewKey());
connect(ui->btn_Copy, &QPushButton::clicked, this, &ViewOnlyDialog::copyToClipboard);
connect(ui->btn_Save, &QPushButton::clicked, this, &ViewOnlyDialog::onWriteViewOnlyWallet);
if (m_ctx->wallet->viewOnly()) {
if (m_wallet->viewOnly()) {
ui->btn_Save->setEnabled(false);
ui->btn_Save->setToolTip("Wallet is already view-only");
}
@@ -45,7 +47,7 @@ void ViewOnlyDialog::onWriteViewOnlyWallet(){
if((bool)passwordDialog.exec())
passwd = passwordDialog.textValue();
m_ctx->wallet->createViewOnly(fn, passwd);
m_wallet->createViewOnly(fn, passwd);
QMessageBox::information(this, "Information", "View-only wallet successfully written to disk.");
}
+3 -3
View File
@@ -6,8 +6,8 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class ViewOnlyDialog;
@@ -18,7 +18,7 @@ class ViewOnlyDialog : public WindowModalDialog
Q_OBJECT
public:
explicit ViewOnlyDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
explicit ViewOnlyDialog(Wallet *wallet, QWidget *parent = nullptr);
~ViewOnlyDialog() override;
private slots:
@@ -28,7 +28,7 @@ private:
void copyToClipboard();
QScopedPointer<Ui::ViewOnlyDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
};
+19 -19
View File
@@ -8,81 +8,81 @@
#include "model/ModelUtils.h"
WalletCacheDebugDialog::WalletCacheDebugDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
WalletCacheDebugDialog::WalletCacheDebugDialog(Wallet *wallet, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::WalletCacheDebugDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
{
ui->setupUi(this);
ui->output->setFont(ModelUtils::getMonospaceFont());
connect(ui->m_blockchain, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printBlockchain());
this->setOutput(m_wallet->printBlockchain());
});
connect(ui->m_transfers, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printTransfers());
this->setOutput(m_wallet->printTransfers());
});
connect(ui->m_unconfirmed_payments, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printUnconfirmedPayments());
this->setOutput(m_wallet->printUnconfirmedPayments());
});
connect(ui->m_confirmed_txs, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printConfirmedTransferDetails());
this->setOutput(m_wallet->printConfirmedTransferDetails());
});
connect(ui->m_unconfirmed_txs, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printUnconfirmedTransferDetails());
this->setOutput(m_wallet->printUnconfirmedTransferDetails());
});
connect(ui->m_payments, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printPayments());
this->setOutput(m_wallet->printPayments());
});
connect(ui->m_pub_keys, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printPubKeys());
this->setOutput(m_wallet->printPubKeys());
});
connect(ui->m_tx_notes, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printTxNotes());
this->setOutput(m_wallet->printTxNotes());
});
connect(ui->m_subaddresses, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printSubaddresses());
this->setOutput(m_wallet->printSubaddresses());
});
connect(ui->m_subaddress_labels, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printSubaddressLabels());
this->setOutput(m_wallet->printSubaddressLabels());
});
connect(ui->m_additional_tx_keys, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printAdditionalTxKeys());
this->setOutput(m_wallet->printAdditionalTxKeys());
});
connect(ui->m_attributes, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printAttributes());
this->setOutput(m_wallet->printAttributes());
});
connect(ui->m_key_images, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printKeyImages());
this->setOutput(m_wallet->printKeyImages());
});
connect(ui->m_account_tags, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printAccountTags());
this->setOutput(m_wallet->printAccountTags());
});
connect(ui->m_tx_keys, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printTxKeys());
this->setOutput(m_wallet->printTxKeys());
});
connect(ui->m_address_book, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printAddressBook());
this->setOutput(m_wallet->printAddressBook());
});
connect(ui->m_scanned_pool_txs, &QRadioButton::pressed, [this]{
this->setOutput(m_ctx->wallet->printScannedPoolTxs());
this->setOutput(m_wallet->printScannedPoolTxs());
});
this->adjustSize();
+3 -3
View File
@@ -6,8 +6,8 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class WalletCacheDebugDialog;
@@ -18,14 +18,14 @@ class WalletCacheDebugDialog : public WindowModalDialog
Q_OBJECT
public:
explicit WalletCacheDebugDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
explicit WalletCacheDebugDialog(Wallet *wallet, QWidget *parent = nullptr);
~WalletCacheDebugDialog() override;
private:
void setOutput(const QString &output);
QScopedPointer<Ui::WalletCacheDebugDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
};
+13 -11
View File
@@ -6,22 +6,24 @@
#include <QDesktopServices>
WalletInfoDialog::WalletInfoDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
#include "utils/Utils.h"
WalletInfoDialog::WalletInfoDialog(Wallet *wallet, QWidget *parent)
: WindowModalDialog(parent)
, ui(new Ui::WalletInfoDialog)
, m_ctx(std::move(ctx))
, m_wallet(wallet)
{
ui->setupUi(this);
QFileInfo cache(m_ctx->wallet->cachePath());
QFileInfo cache(m_wallet->cachePath());
ui->label_walletName->setText(QFileInfo(m_ctx->wallet->cachePath()).fileName());
ui->label_netType->setText(Utils::QtEnumToString(m_ctx->wallet->nettype()));
ui->label_seedType->setText(QString("%1 word").arg(m_ctx->wallet->seedLength()));
ui->label_viewOnly->setText(m_ctx->wallet->viewOnly() ? "True" : "False");
ui->label_subaddressLookahead->setText(m_ctx->wallet->getSubaddressLookahead());
ui->label_keysFile->setText(m_ctx->wallet->keysPath());
ui->label_cacheFile->setText(m_ctx->wallet->cachePath());
ui->label_walletName->setText(QFileInfo(m_wallet->cachePath()).fileName());
ui->label_netType->setText(Utils::QtEnumToString(m_wallet->nettype()));
ui->label_seedType->setText(QString("%1 word").arg(m_wallet->seedLength()));
ui->label_viewOnly->setText(m_wallet->viewOnly() ? "True" : "False");
ui->label_subaddressLookahead->setText(m_wallet->getSubaddressLookahead());
ui->label_keysFile->setText(m_wallet->keysPath());
ui->label_cacheFile->setText(m_wallet->cachePath());
ui->label_cacheSize->setText(QString("%1 MB").arg(QString::number(cache.size() / 1e6, 'f', 2)));
connect(ui->btn_openWalletDir, &QPushButton::clicked, this, &WalletInfoDialog::openWalletDir);
@@ -40,7 +42,7 @@ WalletInfoDialog::WalletInfoDialog(QSharedPointer<AppContext> ctx, QWidget *pare
}
void WalletInfoDialog::openWalletDir() {
QFileInfo file(m_ctx->wallet->keysPath());
QFileInfo file(m_wallet->keysPath());
QDesktopServices::openUrl(QUrl::fromLocalFile(file.absolutePath()));
}
+3 -3
View File
@@ -6,8 +6,8 @@
#include <QDialog>
#include "appcontext.h"
#include "components.h"
#include "libwalletqt/Wallet.h"
namespace Ui {
class WalletInfoDialog;
@@ -18,14 +18,14 @@ class WalletInfoDialog : public WindowModalDialog
Q_OBJECT
public:
explicit WalletInfoDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
explicit WalletInfoDialog(Wallet *wallet, QWidget *parent = nullptr);
~WalletInfoDialog() override;
private:
void openWalletDir();
QScopedPointer<Ui::WalletInfoDialog> ui;
QSharedPointer<AppContext> m_ctx;
Wallet *m_wallet;
};
#endif //FEATHER_WALLETINFODIALOG_H