From 57bb19b94112b7184d89b27d48220855290d5c9b Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 16 Oct 2019 13:26:01 -0700 Subject: [PATCH] Remove turnstile --- src/controller.cpp | 86 ----------------- src/controller.h | 6 -- src/main.cpp | 1 - src/mainwindow.cpp | 17 ---- src/mainwindow.h | 1 - src/turnstile.cpp | 105 -------------------- src/turnstile.h | 37 ------- src/turnstile.ui | 235 --------------------------------------------- zecwallet-lite.pro | 3 - 9 files changed, 491 deletions(-) delete mode 100644 src/turnstile.cpp delete mode 100644 src/turnstile.h delete mode 100644 src/turnstile.ui diff --git a/src/controller.cpp b/src/controller.cpp index 80e8efc..7021187 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -3,7 +3,6 @@ #include "addressbook.h" #include "settings.h" #include "senttxstore.h" -#include "turnstile.h" #include "version.h" #include "websockets.h" @@ -54,9 +53,6 @@ Controller::Controller(MainWindow* main) { // Crate the ZcashdRPC zrpc = new LiteInterface(); - - // Initialize the migration status to unavailable. - this->migrationStatus.available = false; } Controller::~Controller() { @@ -235,66 +231,7 @@ void Controller::getInfoThenRefresh(bool force) { refreshBalances(); refreshAddresses(); // This calls refreshZSentTransactions() and refreshReceivedZTrans() refreshTransactions(); - refreshMigration(); // Sapling turnstile migration status. } - - // Call to see if the blockchain is syncing. - zrpc->fetchBlockchainInfo([=](const json& reply) { - auto progress = reply["verificationprogress"].get(); - bool isSyncing = progress < 0.9999; // 99.99% - int blockNumber = reply["blocks"].get(); - - int estimatedheight = 0; - if (reply.find("estimatedheight") != reply.end()) { - estimatedheight = reply["estimatedheight"].get(); - } - - Settings::getInstance()->setSyncing(isSyncing); - Settings::getInstance()->setBlockNumber(blockNumber); - - // Update zcashd tab if it exists - if (ezcashd) { - if (isSyncing) { - QString txt = QString::number(blockNumber); - if (estimatedheight > 0) { - txt = txt % " / ~" % QString::number(estimatedheight); - } - txt = txt % " ( " % QString::number(progress * 100, 'f', 2) % "% )"; - ui->blockheight->setText(txt); - ui->heightLabel->setText(QObject::tr("Downloading blocks")); - } else { - ui->blockheight->setText(QString::number(blockNumber)); - ui->heightLabel->setText(QObject::tr("Block height")); - } - } - - // Update the status bar - QString statusText = QString() % - (isSyncing ? QObject::tr("Syncing") : QObject::tr("Connected")) % - " (" % - (Settings::getInstance()->isTestnet() ? QObject::tr("testnet:") : "") % - QString::number(blockNumber) % - (isSyncing ? ("/" % QString::number(progress*100, 'f', 2) % "%") : QString()) % - ")"; - main->statusLabel->setText(statusText); - - // Update the balances view to show a warning if the node is still syncing - ui->lblSyncWarning->setVisible(isSyncing); - ui->lblSyncWarningReceive->setVisible(isSyncing); - - auto zecPrice = Settings::getInstance()->getUSDFromZecAmount(1); - QString tooltip; - tooltip = QObject::tr("Connected to zcashd"); - - tooltip = tooltip % "(v " % QString::number(Settings::getInstance()->getZcashdVersion()) % ")"; - - if (!zecPrice.isEmpty()) { - tooltip = "1 " % Settings::getTokenName() % " = " % zecPrice % "\n" % tooltip; - } - main->statusLabel->setToolTip(tooltip); - main->statusIcon->setToolTip(tooltip); - }); - }, [=](QString err) { // zcashd has probably disappeared. this->noConnection(); @@ -378,29 +315,6 @@ bool Controller::processUnspent(const json& reply, QMap* balanc return anyUnconfirmed; }; -/** - * Refresh the turnstile migration status - */ -void Controller::refreshMigration() { - // Turnstile migration is only supported in zcashd v2.0.5 and above - if (Settings::getInstance()->getZcashdVersion() < 2000552) - return; - - zrpc->fetchMigrationStatus([=](json reply) { - this->migrationStatus.available = true; - this->migrationStatus.enabled = reply["enabled"].get(); - this->migrationStatus.saplingAddress = QString::fromStdString(reply["destination_address"]); - this->migrationStatus.unmigrated = QString::fromStdString(reply["unmigrated_amount"]).toDouble(); - this->migrationStatus.migrated = QString::fromStdString(reply["finalized_migrated_amount"]).toDouble(); - - QList ids; - for (auto& it : reply["migration_txids"].get()) { - ids.push_back(QString::fromStdString(it.get())); - } - this->migrationStatus.txids = ids; - }); -} - void Controller::refreshBalances() { if (!zrpc->haveConnection()) return noConnection(); diff --git a/src/controller.h b/src/controller.h index 6de3c51..5c9c43b 100644 --- a/src/controller.h +++ b/src/controller.h @@ -82,14 +82,10 @@ public: QString getDefaultSaplingAddress(); QString getDefaultTAddress(); - const MigrationStatus* getMigrationStatus() { return &migrationStatus; } - void setMigrationStatus(bool status) { zrpc->setMigrationStatus(status); } - private: void refreshBalances(); void refreshTransactions(); - void refreshMigration(); void refreshSentZTrans(); void refreshReceivedZTrans(QList zaddresses); @@ -115,8 +111,6 @@ private: Ui::MainWindow* ui; MainWindow* main; - // Sapling turnstile migration status (for the zcashd v2.0.5 tool) - MigrationStatus migrationStatus; // Current balance in the UI. If this number updates, then refresh the UI QString currentBalance; diff --git a/src/main.cpp b/src/main.cpp index 20fed6a..a10d9ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,6 @@ #include "mainwindow.h" #include "controller.h" #include "settings.h" -#include "turnstile.h" #include "version.h" diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1cded2a..fd49487 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,7 +17,6 @@ #include "balancestablemodel.h" #include "settings.h" #include "version.h" -#include "turnstile.h" #include "senttxstore.h" #include "connection.h" #include "requestdialog.h" @@ -141,7 +140,6 @@ MainWindow::MainWindow(QWidget *parent) : setupTransactionsTab(); setupReceiveTab(); setupBalancesTab(); - setupTurnstileDialog(); setupZcashdTab(); rpc = new Controller(this); @@ -223,21 +221,6 @@ void MainWindow::closeEvent(QCloseEvent* event) { QMainWindow::closeEvent(event); } - -void MainWindow::setupTurnstileDialog() { - // Turnstile migration - QObject::connect(ui->actionTurnstile_Migration, &QAction::triggered, [=] () { - // If the underlying zcashd has support for the migration and there is no existing migration - // in progress, use that. - if (rpc->getMigrationStatus()->available) { - Turnstile::showZcashdMigration(this); - } else { - // Else, do nothing - } - }); - -} - void MainWindow::setupStatusBar() { // Status Bar loadingLabel = new QLabel(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 7593247..4012fb9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -93,7 +93,6 @@ private: void setupBalancesTab(); void setupZcashdTab(); - void setupTurnstileDialog(); void setupSettingsModal(); void setupStatusBar(); diff --git a/src/turnstile.cpp b/src/turnstile.cpp deleted file mode 100644 index da79f33..0000000 --- a/src/turnstile.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "turnstile.h" -#include "mainwindow.h" -#include "balancestablemodel.h" -#include "controller.h" -#include "settings.h" -#include "ui_migration.h" - - -using json = nlohmann::json; - -// Need at least 0.0005 ZEC for this -double Turnstile::minMigrationAmount = 0.0005; - -// Methods for zcashd native Migration -void Turnstile::showZcashdMigration(MainWindow* parent) { - // If it is not enabled, don't show the dialog - if (! parent->getRPC()->getMigrationStatus()->available) - return; - - Ui_MigrationDialog md; - QDialog d(parent); - md.setupUi(&d); - Settings::saveRestore(&d); - - MigrationTxns model(md.tblTxids, parent->getRPC()->getMigrationStatus()->txids); - md.tblTxids->setModel(&model); - - // Table right click - md.tblTxids->setContextMenuPolicy(Qt::CustomContextMenu); - QObject::connect(md.tblTxids, &QTableView::customContextMenuRequested, [=, &model] (QPoint pos) { - QModelIndex index = md.tblTxids->indexAt(pos); - if (index.row() < 0) return; - - QMenu menu(parent); - QString txid = model.getTxid(index.row()); - - menu.addAction("Copy txid", [=]() { - QGuiApplication::clipboard()->setText(txid); - }); - - menu.addAction(QObject::tr("View on block explorer"), [=] () { - QString url; - if (Settings::getInstance()->isTestnet()) { - url = "https://explorer.testnet.z.cash/tx/" + txid; - } else { - url = "https://explorer.zcha.in/transactions/" + txid; - } - QDesktopServices::openUrl(QUrl(url)); - }); - - menu.exec(md.tblTxids->viewport()->mapToGlobal(pos)); - }); - - auto* status = parent->getRPC()->getMigrationStatus(); - - md.chkEnabled->setChecked(status->enabled); - md.lblSaplingAddress->setText(status->saplingAddress); - md.lblUnMigrated->setText(Settings::getZECDisplayFormat(status->unmigrated)); - md.lblMigrated->setText(Settings::getZECDisplayFormat(status->migrated)); - - if (d.exec() == QDialog::Accepted) { - // Update the migration status if it changed - if (md.chkEnabled->isChecked() != status->enabled) { - parent->getRPC()->setMigrationStatus(md.chkEnabled->isChecked()); - } - } -} - - -MigrationTxns::MigrationTxns(QTableView *parent, QList txids) - : QAbstractTableModel(parent) { - headers << tr("Migration Txids"); - this->txids = txids; -} - - -int MigrationTxns::rowCount(const QModelIndex&) const { - return txids.size(); -} - -int MigrationTxns::columnCount(const QModelIndex&) const { - return headers.size(); -} - -QString MigrationTxns::getTxid(int row) const { - return txids.at(row); -} - -QVariant MigrationTxns::data(const QModelIndex &index, int role) const { - if (role == Qt::DisplayRole) { - switch(index.column()) { - case 0: return txids.at(index.row()); - } - } - return QVariant(); -} - - -QVariant MigrationTxns::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { - return headers.at(section); - } - - return QVariant(); -} diff --git a/src/turnstile.h b/src/turnstile.h deleted file mode 100644 index 5af60bf..0000000 --- a/src/turnstile.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef TURNSTILE_H -#define TURNSTILE_H - -#include "precompiled.h" - -class MainWindow; - -class Turnstile -{ -public: - static void showZcashdMigration(MainWindow* parent); - - static double minMigrationAmount; -}; - - -// Classes for zcashd 2.0.5 native migration -class MigrationTxns : public QAbstractTableModel { - -public: - MigrationTxns(QTableView* parent, QList txids); - ~MigrationTxns() = default; - - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - - QString getTxid(int row) const; - -private: - QList txids; - QStringList headers; -}; - - -#endif diff --git a/src/turnstile.ui b/src/turnstile.ui deleted file mode 100644 index 378bfa9..0000000 --- a/src/turnstile.ui +++ /dev/null @@ -1,235 +0,0 @@ - - - Turnstile - - - - 0 - 0 - 565 - 416 - - - - Turnstile Migration - - - - - - Turnstile Migration - - - - - - - - - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Migrate over - - - - - - - - 0 - 0 - - - - From - - - - - - - - 0 - 0 - - - - false - - - - - - - - - - - 0 - 0 - - - - - - - - <html><head/><body><p>Funds from Sprout z-Addresses (which start with &quot;zc&quot;) need to be moved to the upgraded Sapling z-Addresses (which start with &quot;zs&quot;). The funds cannot be moved directly, but need to be sent through intermediate &quot;transparent&quot; addresses in privacy-preserving way.</p><p>This migration can be done automatically for you.</p></body></html> - - - true - - - - - - - - 0 - 0 - - - - To - - - - - - - - - - Qt::Horizontal - - - - - - - Balance - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Miner Fees - - - - - - - - 0 - 0 - - - - 0.0004 ZEC $0.04 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Total Balance - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - AddressCombo - QComboBox -
addresscombo.h
-
-
- - - - buttonBox - accepted() - Turnstile - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Turnstile - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
diff --git a/zecwallet-lite.pro b/zecwallet-lite.pro index ab5ad83..a35333c 100644 --- a/zecwallet-lite.pro +++ b/zecwallet-lite.pro @@ -46,7 +46,6 @@ SOURCES += \ src/sendtab.cpp \ src/senttxstore.cpp \ src/txtablemodel.cpp \ - src/turnstile.cpp \ src/qrcodelabel.cpp \ src/connection.cpp \ src/fillediconlabel.cpp \ @@ -75,7 +74,6 @@ HEADERS += \ src/settings.h \ src/txtablemodel.h \ src/senttxstore.h \ - src/turnstile.h \ src/qrcodelabel.h \ src/connection.h \ src/fillediconlabel.h \ @@ -101,7 +99,6 @@ FORMS += \ src/settings.ui \ src/about.ui \ src/confirm.ui \ - src/turnstile.ui \ src/turnstileprogress.ui \ src/privkey.ui \ src/memodialog.ui \