Remove turnstile
This commit is contained in:
@@ -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<double>();
|
||||
bool isSyncing = progress < 0.9999; // 99.99%
|
||||
int blockNumber = reply["blocks"].get<json::number_unsigned_t>();
|
||||
|
||||
int estimatedheight = 0;
|
||||
if (reply.find("estimatedheight") != reply.end()) {
|
||||
estimatedheight = reply["estimatedheight"].get<json::number_unsigned_t>();
|
||||
}
|
||||
|
||||
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<QString, qint64>* 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<json::boolean_t>();
|
||||
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<QString> ids;
|
||||
for (auto& it : reply["migration_txids"].get<json::array_t>()) {
|
||||
ids.push_back(QString::fromStdString(it.get<json::string_t>()));
|
||||
}
|
||||
this->migrationStatus.txids = ids;
|
||||
});
|
||||
}
|
||||
|
||||
void Controller::refreshBalances() {
|
||||
if (!zrpc->haveConnection())
|
||||
return noConnection();
|
||||
|
||||
@@ -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<QString> 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;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "mainwindow.h"
|
||||
#include "controller.h"
|
||||
#include "settings.h"
|
||||
#include "turnstile.h"
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -93,7 +93,6 @@ private:
|
||||
void setupBalancesTab();
|
||||
void setupZcashdTab();
|
||||
|
||||
void setupTurnstileDialog();
|
||||
void setupSettingsModal();
|
||||
void setupStatusBar();
|
||||
|
||||
|
||||
@@ -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<QString> 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();
|
||||
}
|
||||
@@ -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<QString> 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<QString> txids;
|
||||
QStringList headers;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
235
src/turnstile.ui
235
src/turnstile.ui
@@ -1,235 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Turnstile</class>
|
||||
<widget class="QDialog" name="Turnstile">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>565</width>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Turnstile Migration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Turnstile Migration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="msgIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Migrate over</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="AddressCombo" name="migrateZaddList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="privLevel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="AddressCombo" name="migrateTo"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="fromBalance">
|
||||
<property name="text">
|
||||
<string>Balance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" rowspan="2" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Miner Fees</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="2">
|
||||
<widget class="QLabel" name="minerFee">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">0.0004 ZEC $0.04</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Total Balance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AddressCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>addresscombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Turnstile</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Turnstile</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user