From 89dda8eebe8b900e856c8d2ffb1c131293577787 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 22 Oct 2018 22:10:52 -0700 Subject: [PATCH 01/10] Turnstile prototype --- src/mainwindow.cpp | 35 ++++++ src/mainwindow.ui | 12 ++ src/turnstile.ui | 229 +++++++++++++++++++++++++++++++++++++ src/turnstileprogress.ui | 154 +++++++++++++++++++++++++ src/ui_mainwindow.h | 10 ++ src/ui_turnstile.h | 210 ++++++++++++++++++++++++++++++++++ src/ui_turnstileprogress.h | 141 +++++++++++++++++++++++ zcash-qt-wallet.pro | 4 +- 8 files changed, 794 insertions(+), 1 deletion(-) create mode 100644 src/turnstile.ui create mode 100644 src/turnstileprogress.ui create mode 100644 src/ui_turnstile.h create mode 100644 src/ui_turnstileprogress.h diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 28fac81..9249eef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,11 +2,14 @@ #include "ui_mainwindow.h" #include "ui_about.h" #include "ui_settings.h" +#include "ui_turnstile.h" +#include "ui_turnstileprogress.h" #include "rpc.h" #include "balancestablemodel.h" #include "settings.h" #include "utils.h" + #include "precompiled.h" @@ -24,6 +27,38 @@ MainWindow::MainWindow(QWidget *parent) : // Settings editor setupSettingsModal(); + // Turnstile migration + QObject::connect(ui->actionTurnstile_Migration, &QAction::triggered, [=] () { + Ui_Turnstile turnstile; + QDialog d(this); + turnstile.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); + turnstile.msgIcon->setPixmap(icon.pixmap(64, 64)); + + turnstile.migrateZaddList->addItem("All Sprout z-Addrs"); + turnstile.migrateTo->addItem("zs1gv64eu0v2wx7raxqxlmj354y9ycznwaau9kduljzczxztvs4qcl00kn2sjxtejvrxnkucw5xx9u"); + turnstile.privLevel->addItem("Good - 3 tx over 3 days"); + turnstile.privLevel->addItem("Excellent - 5 tx over 5 days"); + turnstile.privLevel->addItem("Paranoid - 10 tx over 7 days"); + + turnstile.buttonBox->button(QDialogButtonBox::Ok)->setText("Start"); + + d.exec(); + }); + + QObject::connect(ui->actionProgress, &QAction::triggered, [=] () { + Ui_TurnstileProgress progress; + QDialog d(this); + progress.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); + progress.msgIcon->setPixmap(icon.pixmap(64, 64)); + + progress.buttonBox->button(QDialogButtonBox::Cancel)->setText("Abort"); + d.exec(); + }); + // Set up exit action QObject::connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f429a8f..5f4fb98 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -720,6 +720,8 @@ File + + @@ -769,6 +771,16 @@ Check github.com for Updates + + + Turnstile Migration + + + + + Progress + + diff --git a/src/turnstile.ui b/src/turnstile.ui new file mode 100644 index 0000000..a12af05 --- /dev/null +++ b/src/turnstile.ui @@ -0,0 +1,229 @@ + + + Turnstile + + + + 0 + 0 + 565 + 416 + + + + Turnstile Migration + + + + + + Turnstile Migration + + + + + + + + + + + Qt::AlignCenter + + + + + + + Total Fees + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Privacy Level + + + + + + + + 0 + 0 + + + + Miner Fee: + + + + + + + + 0 + 0 + + + + From + + + + + + + + 0 + 0 + + + + Dev Fee: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0.0004 ZEC $0.04 + + + + + + + 0.0004 ZEC $0.04 + + + + + + + + 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 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Turnstile + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Turnstile + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/turnstileprogress.ui b/src/turnstileprogress.ui new file mode 100644 index 0000000..5b09ebd --- /dev/null +++ b/src/turnstileprogress.ui @@ -0,0 +1,154 @@ + + + TurnstileProgress + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + 33 + + + + + + + + 0 + 0 + + + + Please Ensure you have your wallet.dat backed up! + + + true + + + + + + + Qt::Horizontal + + + + + + + Next Transaction in 4 hours + + + + + + + 4 / 12 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Migration Progress + + + + + + + + 0 + 0 + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + + + buttonBox + accepted() + TurnstileProgress + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + TurnstileProgress + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/ui_mainwindow.h b/src/ui_mainwindow.h index a0f8192..3c9f656 100644 --- a/src/ui_mainwindow.h +++ b/src/ui_mainwindow.h @@ -47,6 +47,8 @@ public: QAction *actionDonate; QAction *actionImport_Private_Keys; QAction *actionCheck_for_Updates; + QAction *actionTurnstile_Migration; + QAction *actionProgress; QWidget *centralWidget; QGridLayout *gridLayout_3; QTabWidget *tabWidget; @@ -159,6 +161,10 @@ public: actionImport_Private_Keys->setVisible(false); actionCheck_for_Updates = new QAction(MainWindow); actionCheck_for_Updates->setObjectName(QStringLiteral("actionCheck_for_Updates")); + actionTurnstile_Migration = new QAction(MainWindow); + actionTurnstile_Migration->setObjectName(QStringLiteral("actionTurnstile_Migration")); + actionProgress = new QAction(MainWindow); + actionProgress->setObjectName(QStringLiteral("actionProgress")); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); gridLayout_3 = new QGridLayout(centralWidget); @@ -666,6 +672,8 @@ public: menuBar->addAction(menuBalance->menuAction()); menuBar->addAction(menuHelp->menuAction()); menuBalance->addAction(actionImport_Private_Keys); + menuBalance->addAction(actionTurnstile_Migration); + menuBalance->addAction(actionProgress); menuBalance->addAction(actionSettings); menuBalance->addSeparator(); menuBalance->addAction(actionExit); @@ -690,6 +698,8 @@ public: actionDonate->setText(QApplication::translate("MainWindow", "Donate", nullptr)); actionImport_Private_Keys->setText(QApplication::translate("MainWindow", "Import Private Keys", nullptr)); actionCheck_for_Updates->setText(QApplication::translate("MainWindow", "Check github.com for Updates", nullptr)); + actionTurnstile_Migration->setText(QApplication::translate("MainWindow", "Turnstile Migration", nullptr)); + actionProgress->setText(QApplication::translate("MainWindow", "Progress", nullptr)); groupBox->setTitle(QApplication::translate("MainWindow", "Summary", nullptr)); label->setText(QApplication::translate("MainWindow", "Shielded", nullptr)); balSheilded->setText(QString()); diff --git a/src/ui_turnstile.h b/src/ui_turnstile.h new file mode 100644 index 0000000..8eb3566 --- /dev/null +++ b/src/ui_turnstile.h @@ -0,0 +1,210 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstile.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILE_H +#define UI_TURNSTILE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_Turnstile +{ +public: + QVBoxLayout *verticalLayout; + QGroupBox *groupBox; + QVBoxLayout *verticalLayout_2; + QGridLayout *gridLayout; + QLabel *msgIcon; + QLabel *label_3; + QLabel *label_2; + QLabel *label_4; + QLabel *label; + QLabel *label_5; + QSpacerItem *verticalSpacer; + QLabel *label_6; + QLabel *label_7; + QComboBox *migrateZaddList; + QComboBox *privLevel; + QLabel *label_8; + QLabel *label_9; + QComboBox *migrateTo; + QFrame *line; + QDialogButtonBox *buttonBox; + + void setupUi(QDialog *Turnstile) + { + if (Turnstile->objectName().isEmpty()) + Turnstile->setObjectName(QStringLiteral("Turnstile")); + Turnstile->resize(565, 416); + verticalLayout = new QVBoxLayout(Turnstile); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + groupBox = new QGroupBox(Turnstile); + groupBox->setObjectName(QStringLiteral("groupBox")); + verticalLayout_2 = new QVBoxLayout(groupBox); + verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); + gridLayout = new QGridLayout(); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + msgIcon = new QLabel(groupBox); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 0, 0, 1, 1); + + label_3 = new QLabel(groupBox); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); + + gridLayout->addWidget(label_3, 5, 0, 2, 1); + + label_2 = new QLabel(groupBox); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 4, 0, 1, 1); + + label_4 = new QLabel(groupBox); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_4, 5, 1, 1, 1); + + label = new QLabel(groupBox); + label->setObjectName(QStringLiteral("label")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); + label->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label, 2, 0, 1, 1); + + label_5 = new QLabel(groupBox); + label_5->setObjectName(QStringLiteral("label_5")); + sizePolicy.setHeightForWidth(label_5->sizePolicy().hasHeightForWidth()); + label_5->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_5, 6, 1, 1, 1); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 7, 0, 1, 2); + + label_6 = new QLabel(groupBox); + label_6->setObjectName(QStringLiteral("label_6")); + + gridLayout->addWidget(label_6, 5, 2, 1, 1); + + label_7 = new QLabel(groupBox); + label_7->setObjectName(QStringLiteral("label_7")); + + gridLayout->addWidget(label_7, 6, 2, 1, 1); + + migrateZaddList = new QComboBox(groupBox); + migrateZaddList->setObjectName(QStringLiteral("migrateZaddList")); + QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(migrateZaddList->sizePolicy().hasHeightForWidth()); + migrateZaddList->setSizePolicy(sizePolicy2); + migrateZaddList->setEditable(false); + + gridLayout->addWidget(migrateZaddList, 2, 1, 1, 2); + + privLevel = new QComboBox(groupBox); + privLevel->setObjectName(QStringLiteral("privLevel")); + sizePolicy2.setHeightForWidth(privLevel->sizePolicy().hasHeightForWidth()); + privLevel->setSizePolicy(sizePolicy2); + + gridLayout->addWidget(privLevel, 4, 1, 1, 2); + + label_8 = new QLabel(groupBox); + label_8->setObjectName(QStringLiteral("label_8")); + label_8->setWordWrap(true); + + gridLayout->addWidget(label_8, 0, 1, 1, 2); + + label_9 = new QLabel(groupBox); + label_9->setObjectName(QStringLiteral("label_9")); + sizePolicy1.setHeightForWidth(label_9->sizePolicy().hasHeightForWidth()); + label_9->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label_9, 3, 0, 1, 1); + + migrateTo = new QComboBox(groupBox); + migrateTo->setObjectName(QStringLiteral("migrateTo")); + + gridLayout->addWidget(migrateTo, 3, 1, 1, 2); + + line = new QFrame(groupBox); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 1, 0, 1, 3); + + + verticalLayout_2->addLayout(gridLayout); + + + verticalLayout->addWidget(groupBox); + + buttonBox = new QDialogButtonBox(Turnstile); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + verticalLayout->addWidget(buttonBox); + + + retranslateUi(Turnstile); + QObject::connect(buttonBox, SIGNAL(accepted()), Turnstile, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), Turnstile, SLOT(reject())); + + QMetaObject::connectSlotsByName(Turnstile); + } // setupUi + + void retranslateUi(QDialog *Turnstile) + { + Turnstile->setWindowTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + groupBox->setTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + msgIcon->setText(QString()); + label_3->setText(QApplication::translate("Turnstile", "Total Fees", nullptr)); + label_2->setText(QApplication::translate("Turnstile", "Privacy Level", nullptr)); + label_4->setText(QApplication::translate("Turnstile", "Miner Fee:", nullptr)); + label->setText(QApplication::translate("Turnstile", "From", nullptr)); + label_5->setText(QApplication::translate("Turnstile", "Dev Fee: ", nullptr)); + label_6->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + label_7->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + migrateZaddList->setCurrentText(QString()); + label_8->setText(QApplication::translate("Turnstile", "

Funds from Sprout z-Addresses (which start with "zc") need to be moved to the upgraded Sapling z-Addresses (which start with "zs"). The funds cannot be moved directly, but need to be sent through intermediate "transparent" addresses in privacy-preserving way.

This migration can be done automatically for you.

", nullptr)); + label_9->setText(QApplication::translate("Turnstile", "To", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class Turnstile: public Ui_Turnstile {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILE_H diff --git a/src/ui_turnstileprogress.h b/src/ui_turnstileprogress.h new file mode 100644 index 0000000..2d34909 --- /dev/null +++ b/src/ui_turnstileprogress.h @@ -0,0 +1,141 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstileprogress.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILEPROGRESS_H +#define UI_TURNSTILEPROGRESS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_TurnstileProgress +{ +public: + QGridLayout *gridLayout; + QProgressBar *progressBar; + QLabel *label_4; + QFrame *line; + QLabel *label; + QLabel *label_3; + QLabel *label_2; + QLabel *msgIcon; + QDialogButtonBox *buttonBox; + QSpacerItem *verticalSpacer; + QFrame *line_2; + + void setupUi(QDialog *TurnstileProgress) + { + if (TurnstileProgress->objectName().isEmpty()) + TurnstileProgress->setObjectName(QStringLiteral("TurnstileProgress")); + TurnstileProgress->resize(400, 300); + gridLayout = new QGridLayout(TurnstileProgress); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + progressBar = new QProgressBar(TurnstileProgress); + progressBar->setObjectName(QStringLiteral("progressBar")); + progressBar->setValue(33); + + gridLayout->addWidget(progressBar, 3, 0, 1, 3); + + label_4 = new QLabel(TurnstileProgress); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + label_4->setWordWrap(true); + + gridLayout->addWidget(label_4, 7, 1, 1, 2); + + line = new QFrame(TurnstileProgress); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 4, 0, 1, 3); + + label = new QLabel(TurnstileProgress); + label->setObjectName(QStringLiteral("label")); + + gridLayout->addWidget(label, 5, 0, 1, 3); + + label_3 = new QLabel(TurnstileProgress); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + + gridLayout->addWidget(label_3, 2, 2, 1, 1); + + label_2 = new QLabel(TurnstileProgress); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 2, 0, 1, 2); + + msgIcon = new QLabel(TurnstileProgress); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(msgIcon->sizePolicy().hasHeightForWidth()); + msgIcon->setSizePolicy(sizePolicy1); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 7, 0, 1, 1); + + buttonBox = new QDialogButtonBox(TurnstileProgress); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + gridLayout->addWidget(buttonBox, 9, 0, 1, 3); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 6, 0, 1, 3); + + line_2 = new QFrame(TurnstileProgress); + line_2->setObjectName(QStringLiteral("line_2")); + line_2->setFrameShape(QFrame::HLine); + line_2->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line_2, 8, 0, 1, 3); + + + retranslateUi(TurnstileProgress); + QObject::connect(buttonBox, SIGNAL(accepted()), TurnstileProgress, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), TurnstileProgress, SLOT(reject())); + + QMetaObject::connectSlotsByName(TurnstileProgress); + } // setupUi + + void retranslateUi(QDialog *TurnstileProgress) + { + TurnstileProgress->setWindowTitle(QApplication::translate("TurnstileProgress", "Dialog", nullptr)); + label_4->setText(QApplication::translate("TurnstileProgress", "Please Ensure you have your wallet.dat backed up!", nullptr)); + label->setText(QApplication::translate("TurnstileProgress", "Next Transaction in 4 hours", nullptr)); + label_3->setText(QApplication::translate("TurnstileProgress", "4 / 12", nullptr)); + label_2->setText(QApplication::translate("TurnstileProgress", "Migration Progress", nullptr)); + msgIcon->setText(QApplication::translate("TurnstileProgress", "TextLabel", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class TurnstileProgress: public Ui_TurnstileProgress {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILEPROGRESS_H diff --git a/zcash-qt-wallet.pro b/zcash-qt-wallet.pro index 5130567..7420b5c 100644 --- a/zcash-qt-wallet.pro +++ b/zcash-qt-wallet.pro @@ -71,7 +71,9 @@ FORMS += \ src/mainwindow.ui \ src/settings.ui \ src/about.ui \ - src/confirm.ui + src/confirm.ui \ + src/turnstile.ui \ + src/turnstileprogress.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin From 90cf9d68965f3f534c26622e478493688c14706a Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 22 Oct 2018 22:10:52 -0700 Subject: [PATCH 02/10] Turnstile prototype --- src/mainwindow.cpp | 35 ++++++ src/mainwindow.ui | 12 ++ src/turnstile.ui | 229 +++++++++++++++++++++++++++++++++++++ src/turnstileprogress.ui | 154 +++++++++++++++++++++++++ src/ui_mainwindow.h | 10 ++ src/ui_turnstile.h | 210 ++++++++++++++++++++++++++++++++++ src/ui_turnstileprogress.h | 141 +++++++++++++++++++++++ zcash-qt-wallet.pro | 4 +- 8 files changed, 794 insertions(+), 1 deletion(-) create mode 100644 src/turnstile.ui create mode 100644 src/turnstileprogress.ui create mode 100644 src/ui_turnstile.h create mode 100644 src/ui_turnstileprogress.h diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1c7c6d4..fe33645 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,12 +2,15 @@ #include "ui_mainwindow.h" #include "ui_about.h" #include "ui_settings.h" +#include "ui_turnstile.h" +#include "ui_turnstileprogress.h" #include "rpc.h" #include "balancestablemodel.h" #include "settings.h" #include "utils.h" #include "senttxstore.h" + #include "precompiled.h" using json = nlohmann::json; @@ -24,6 +27,38 @@ MainWindow::MainWindow(QWidget *parent) : // Settings editor setupSettingsModal(); + // Turnstile migration + QObject::connect(ui->actionTurnstile_Migration, &QAction::triggered, [=] () { + Ui_Turnstile turnstile; + QDialog d(this); + turnstile.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); + turnstile.msgIcon->setPixmap(icon.pixmap(64, 64)); + + turnstile.migrateZaddList->addItem("All Sprout z-Addrs"); + turnstile.migrateTo->addItem("zs1gv64eu0v2wx7raxqxlmj354y9ycznwaau9kduljzczxztvs4qcl00kn2sjxtejvrxnkucw5xx9u"); + turnstile.privLevel->addItem("Good - 3 tx over 3 days"); + turnstile.privLevel->addItem("Excellent - 5 tx over 5 days"); + turnstile.privLevel->addItem("Paranoid - 10 tx over 7 days"); + + turnstile.buttonBox->button(QDialogButtonBox::Ok)->setText("Start"); + + d.exec(); + }); + + QObject::connect(ui->actionProgress, &QAction::triggered, [=] () { + Ui_TurnstileProgress progress; + QDialog d(this); + progress.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); + progress.msgIcon->setPixmap(icon.pixmap(64, 64)); + + progress.buttonBox->button(QDialogButtonBox::Cancel)->setText("Abort"); + d.exec(); + }); + // Set up exit action QObject::connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f429a8f..5f4fb98 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -720,6 +720,8 @@ File + + @@ -769,6 +771,16 @@ Check github.com for Updates + + + Turnstile Migration + + + + + Progress + + diff --git a/src/turnstile.ui b/src/turnstile.ui new file mode 100644 index 0000000..a12af05 --- /dev/null +++ b/src/turnstile.ui @@ -0,0 +1,229 @@ + + + Turnstile + + + + 0 + 0 + 565 + 416 + + + + Turnstile Migration + + + + + + Turnstile Migration + + + + + + + + + + + Qt::AlignCenter + + + + + + + Total Fees + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Privacy Level + + + + + + + + 0 + 0 + + + + Miner Fee: + + + + + + + + 0 + 0 + + + + From + + + + + + + + 0 + 0 + + + + Dev Fee: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0.0004 ZEC $0.04 + + + + + + + 0.0004 ZEC $0.04 + + + + + + + + 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 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Turnstile + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Turnstile + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/turnstileprogress.ui b/src/turnstileprogress.ui new file mode 100644 index 0000000..5b09ebd --- /dev/null +++ b/src/turnstileprogress.ui @@ -0,0 +1,154 @@ + + + TurnstileProgress + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + 33 + + + + + + + + 0 + 0 + + + + Please Ensure you have your wallet.dat backed up! + + + true + + + + + + + Qt::Horizontal + + + + + + + Next Transaction in 4 hours + + + + + + + 4 / 12 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Migration Progress + + + + + + + + 0 + 0 + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + + + buttonBox + accepted() + TurnstileProgress + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + TurnstileProgress + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/ui_mainwindow.h b/src/ui_mainwindow.h index a0f8192..3c9f656 100644 --- a/src/ui_mainwindow.h +++ b/src/ui_mainwindow.h @@ -47,6 +47,8 @@ public: QAction *actionDonate; QAction *actionImport_Private_Keys; QAction *actionCheck_for_Updates; + QAction *actionTurnstile_Migration; + QAction *actionProgress; QWidget *centralWidget; QGridLayout *gridLayout_3; QTabWidget *tabWidget; @@ -159,6 +161,10 @@ public: actionImport_Private_Keys->setVisible(false); actionCheck_for_Updates = new QAction(MainWindow); actionCheck_for_Updates->setObjectName(QStringLiteral("actionCheck_for_Updates")); + actionTurnstile_Migration = new QAction(MainWindow); + actionTurnstile_Migration->setObjectName(QStringLiteral("actionTurnstile_Migration")); + actionProgress = new QAction(MainWindow); + actionProgress->setObjectName(QStringLiteral("actionProgress")); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); gridLayout_3 = new QGridLayout(centralWidget); @@ -666,6 +672,8 @@ public: menuBar->addAction(menuBalance->menuAction()); menuBar->addAction(menuHelp->menuAction()); menuBalance->addAction(actionImport_Private_Keys); + menuBalance->addAction(actionTurnstile_Migration); + menuBalance->addAction(actionProgress); menuBalance->addAction(actionSettings); menuBalance->addSeparator(); menuBalance->addAction(actionExit); @@ -690,6 +698,8 @@ public: actionDonate->setText(QApplication::translate("MainWindow", "Donate", nullptr)); actionImport_Private_Keys->setText(QApplication::translate("MainWindow", "Import Private Keys", nullptr)); actionCheck_for_Updates->setText(QApplication::translate("MainWindow", "Check github.com for Updates", nullptr)); + actionTurnstile_Migration->setText(QApplication::translate("MainWindow", "Turnstile Migration", nullptr)); + actionProgress->setText(QApplication::translate("MainWindow", "Progress", nullptr)); groupBox->setTitle(QApplication::translate("MainWindow", "Summary", nullptr)); label->setText(QApplication::translate("MainWindow", "Shielded", nullptr)); balSheilded->setText(QString()); diff --git a/src/ui_turnstile.h b/src/ui_turnstile.h new file mode 100644 index 0000000..8eb3566 --- /dev/null +++ b/src/ui_turnstile.h @@ -0,0 +1,210 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstile.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILE_H +#define UI_TURNSTILE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_Turnstile +{ +public: + QVBoxLayout *verticalLayout; + QGroupBox *groupBox; + QVBoxLayout *verticalLayout_2; + QGridLayout *gridLayout; + QLabel *msgIcon; + QLabel *label_3; + QLabel *label_2; + QLabel *label_4; + QLabel *label; + QLabel *label_5; + QSpacerItem *verticalSpacer; + QLabel *label_6; + QLabel *label_7; + QComboBox *migrateZaddList; + QComboBox *privLevel; + QLabel *label_8; + QLabel *label_9; + QComboBox *migrateTo; + QFrame *line; + QDialogButtonBox *buttonBox; + + void setupUi(QDialog *Turnstile) + { + if (Turnstile->objectName().isEmpty()) + Turnstile->setObjectName(QStringLiteral("Turnstile")); + Turnstile->resize(565, 416); + verticalLayout = new QVBoxLayout(Turnstile); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + groupBox = new QGroupBox(Turnstile); + groupBox->setObjectName(QStringLiteral("groupBox")); + verticalLayout_2 = new QVBoxLayout(groupBox); + verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); + gridLayout = new QGridLayout(); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + msgIcon = new QLabel(groupBox); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 0, 0, 1, 1); + + label_3 = new QLabel(groupBox); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); + + gridLayout->addWidget(label_3, 5, 0, 2, 1); + + label_2 = new QLabel(groupBox); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 4, 0, 1, 1); + + label_4 = new QLabel(groupBox); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_4, 5, 1, 1, 1); + + label = new QLabel(groupBox); + label->setObjectName(QStringLiteral("label")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); + label->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label, 2, 0, 1, 1); + + label_5 = new QLabel(groupBox); + label_5->setObjectName(QStringLiteral("label_5")); + sizePolicy.setHeightForWidth(label_5->sizePolicy().hasHeightForWidth()); + label_5->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_5, 6, 1, 1, 1); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 7, 0, 1, 2); + + label_6 = new QLabel(groupBox); + label_6->setObjectName(QStringLiteral("label_6")); + + gridLayout->addWidget(label_6, 5, 2, 1, 1); + + label_7 = new QLabel(groupBox); + label_7->setObjectName(QStringLiteral("label_7")); + + gridLayout->addWidget(label_7, 6, 2, 1, 1); + + migrateZaddList = new QComboBox(groupBox); + migrateZaddList->setObjectName(QStringLiteral("migrateZaddList")); + QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(migrateZaddList->sizePolicy().hasHeightForWidth()); + migrateZaddList->setSizePolicy(sizePolicy2); + migrateZaddList->setEditable(false); + + gridLayout->addWidget(migrateZaddList, 2, 1, 1, 2); + + privLevel = new QComboBox(groupBox); + privLevel->setObjectName(QStringLiteral("privLevel")); + sizePolicy2.setHeightForWidth(privLevel->sizePolicy().hasHeightForWidth()); + privLevel->setSizePolicy(sizePolicy2); + + gridLayout->addWidget(privLevel, 4, 1, 1, 2); + + label_8 = new QLabel(groupBox); + label_8->setObjectName(QStringLiteral("label_8")); + label_8->setWordWrap(true); + + gridLayout->addWidget(label_8, 0, 1, 1, 2); + + label_9 = new QLabel(groupBox); + label_9->setObjectName(QStringLiteral("label_9")); + sizePolicy1.setHeightForWidth(label_9->sizePolicy().hasHeightForWidth()); + label_9->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label_9, 3, 0, 1, 1); + + migrateTo = new QComboBox(groupBox); + migrateTo->setObjectName(QStringLiteral("migrateTo")); + + gridLayout->addWidget(migrateTo, 3, 1, 1, 2); + + line = new QFrame(groupBox); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 1, 0, 1, 3); + + + verticalLayout_2->addLayout(gridLayout); + + + verticalLayout->addWidget(groupBox); + + buttonBox = new QDialogButtonBox(Turnstile); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + verticalLayout->addWidget(buttonBox); + + + retranslateUi(Turnstile); + QObject::connect(buttonBox, SIGNAL(accepted()), Turnstile, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), Turnstile, SLOT(reject())); + + QMetaObject::connectSlotsByName(Turnstile); + } // setupUi + + void retranslateUi(QDialog *Turnstile) + { + Turnstile->setWindowTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + groupBox->setTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + msgIcon->setText(QString()); + label_3->setText(QApplication::translate("Turnstile", "Total Fees", nullptr)); + label_2->setText(QApplication::translate("Turnstile", "Privacy Level", nullptr)); + label_4->setText(QApplication::translate("Turnstile", "Miner Fee:", nullptr)); + label->setText(QApplication::translate("Turnstile", "From", nullptr)); + label_5->setText(QApplication::translate("Turnstile", "Dev Fee: ", nullptr)); + label_6->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + label_7->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + migrateZaddList->setCurrentText(QString()); + label_8->setText(QApplication::translate("Turnstile", "

Funds from Sprout z-Addresses (which start with "zc") need to be moved to the upgraded Sapling z-Addresses (which start with "zs"). The funds cannot be moved directly, but need to be sent through intermediate "transparent" addresses in privacy-preserving way.

This migration can be done automatically for you.

", nullptr)); + label_9->setText(QApplication::translate("Turnstile", "To", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class Turnstile: public Ui_Turnstile {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILE_H diff --git a/src/ui_turnstileprogress.h b/src/ui_turnstileprogress.h new file mode 100644 index 0000000..2d34909 --- /dev/null +++ b/src/ui_turnstileprogress.h @@ -0,0 +1,141 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstileprogress.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILEPROGRESS_H +#define UI_TURNSTILEPROGRESS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_TurnstileProgress +{ +public: + QGridLayout *gridLayout; + QProgressBar *progressBar; + QLabel *label_4; + QFrame *line; + QLabel *label; + QLabel *label_3; + QLabel *label_2; + QLabel *msgIcon; + QDialogButtonBox *buttonBox; + QSpacerItem *verticalSpacer; + QFrame *line_2; + + void setupUi(QDialog *TurnstileProgress) + { + if (TurnstileProgress->objectName().isEmpty()) + TurnstileProgress->setObjectName(QStringLiteral("TurnstileProgress")); + TurnstileProgress->resize(400, 300); + gridLayout = new QGridLayout(TurnstileProgress); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + progressBar = new QProgressBar(TurnstileProgress); + progressBar->setObjectName(QStringLiteral("progressBar")); + progressBar->setValue(33); + + gridLayout->addWidget(progressBar, 3, 0, 1, 3); + + label_4 = new QLabel(TurnstileProgress); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + label_4->setWordWrap(true); + + gridLayout->addWidget(label_4, 7, 1, 1, 2); + + line = new QFrame(TurnstileProgress); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 4, 0, 1, 3); + + label = new QLabel(TurnstileProgress); + label->setObjectName(QStringLiteral("label")); + + gridLayout->addWidget(label, 5, 0, 1, 3); + + label_3 = new QLabel(TurnstileProgress); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + + gridLayout->addWidget(label_3, 2, 2, 1, 1); + + label_2 = new QLabel(TurnstileProgress); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 2, 0, 1, 2); + + msgIcon = new QLabel(TurnstileProgress); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(msgIcon->sizePolicy().hasHeightForWidth()); + msgIcon->setSizePolicy(sizePolicy1); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 7, 0, 1, 1); + + buttonBox = new QDialogButtonBox(TurnstileProgress); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + gridLayout->addWidget(buttonBox, 9, 0, 1, 3); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 6, 0, 1, 3); + + line_2 = new QFrame(TurnstileProgress); + line_2->setObjectName(QStringLiteral("line_2")); + line_2->setFrameShape(QFrame::HLine); + line_2->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line_2, 8, 0, 1, 3); + + + retranslateUi(TurnstileProgress); + QObject::connect(buttonBox, SIGNAL(accepted()), TurnstileProgress, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), TurnstileProgress, SLOT(reject())); + + QMetaObject::connectSlotsByName(TurnstileProgress); + } // setupUi + + void retranslateUi(QDialog *TurnstileProgress) + { + TurnstileProgress->setWindowTitle(QApplication::translate("TurnstileProgress", "Dialog", nullptr)); + label_4->setText(QApplication::translate("TurnstileProgress", "Please Ensure you have your wallet.dat backed up!", nullptr)); + label->setText(QApplication::translate("TurnstileProgress", "Next Transaction in 4 hours", nullptr)); + label_3->setText(QApplication::translate("TurnstileProgress", "4 / 12", nullptr)); + label_2->setText(QApplication::translate("TurnstileProgress", "Migration Progress", nullptr)); + msgIcon->setText(QApplication::translate("TurnstileProgress", "TextLabel", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class TurnstileProgress: public Ui_TurnstileProgress {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILEPROGRESS_H diff --git a/zcash-qt-wallet.pro b/zcash-qt-wallet.pro index 2a9bf3b..6abb239 100644 --- a/zcash-qt-wallet.pro +++ b/zcash-qt-wallet.pro @@ -71,7 +71,9 @@ FORMS += \ src/mainwindow.ui \ src/settings.ui \ src/about.ui \ - src/confirm.ui + src/confirm.ui \ + src/turnstile.ui \ + src/turnstileprogress.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin From 4929dd417ca31aaa607edf0cc4c31dbc80b34c9b Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 22 Oct 2018 22:10:52 -0700 Subject: [PATCH 03/10] Turnstile prototype --- src/mainwindow.cpp | 35 ++++++ src/mainwindow.ui | 12 ++ src/turnstile.ui | 229 +++++++++++++++++++++++++++++++++++++ src/turnstileprogress.ui | 154 +++++++++++++++++++++++++ src/ui_mainwindow.h | 10 ++ src/ui_turnstile.h | 210 ++++++++++++++++++++++++++++++++++ src/ui_turnstileprogress.h | 141 +++++++++++++++++++++++ zec-qt-wallet.pro | 4 +- 8 files changed, 794 insertions(+), 1 deletion(-) create mode 100644 src/turnstile.ui create mode 100644 src/turnstileprogress.ui create mode 100644 src/ui_turnstile.h create mode 100644 src/ui_turnstileprogress.h diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2606f6d..d03c0a6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,12 +2,15 @@ #include "ui_mainwindow.h" #include "ui_about.h" #include "ui_settings.h" +#include "ui_turnstile.h" +#include "ui_turnstileprogress.h" #include "rpc.h" #include "balancestablemodel.h" #include "settings.h" #include "utils.h" #include "senttxstore.h" + #include "precompiled.h" using json = nlohmann::json; @@ -24,6 +27,38 @@ MainWindow::MainWindow(QWidget *parent) : // Settings editor setupSettingsModal(); + // Turnstile migration + QObject::connect(ui->actionTurnstile_Migration, &QAction::triggered, [=] () { + Ui_Turnstile turnstile; + QDialog d(this); + turnstile.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); + turnstile.msgIcon->setPixmap(icon.pixmap(64, 64)); + + turnstile.migrateZaddList->addItem("All Sprout z-Addrs"); + turnstile.migrateTo->addItem("zs1gv64eu0v2wx7raxqxlmj354y9ycznwaau9kduljzczxztvs4qcl00kn2sjxtejvrxnkucw5xx9u"); + turnstile.privLevel->addItem("Good - 3 tx over 3 days"); + turnstile.privLevel->addItem("Excellent - 5 tx over 5 days"); + turnstile.privLevel->addItem("Paranoid - 10 tx over 7 days"); + + turnstile.buttonBox->button(QDialogButtonBox::Ok)->setText("Start"); + + d.exec(); + }); + + QObject::connect(ui->actionProgress, &QAction::triggered, [=] () { + Ui_TurnstileProgress progress; + QDialog d(this); + progress.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); + progress.msgIcon->setPixmap(icon.pixmap(64, 64)); + + progress.buttonBox->button(QDialogButtonBox::Cancel)->setText("Abort"); + d.exec(); + }); + // Set up exit action QObject::connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 4baf922..9e408c4 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -720,6 +720,8 @@ File + + @@ -769,6 +771,16 @@ Check github.com for Updates + + + Turnstile Migration + + + + + Progress + + diff --git a/src/turnstile.ui b/src/turnstile.ui new file mode 100644 index 0000000..a12af05 --- /dev/null +++ b/src/turnstile.ui @@ -0,0 +1,229 @@ + + + Turnstile + + + + 0 + 0 + 565 + 416 + + + + Turnstile Migration + + + + + + Turnstile Migration + + + + + + + + + + + Qt::AlignCenter + + + + + + + Total Fees + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Privacy Level + + + + + + + + 0 + 0 + + + + Miner Fee: + + + + + + + + 0 + 0 + + + + From + + + + + + + + 0 + 0 + + + + Dev Fee: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0.0004 ZEC $0.04 + + + + + + + 0.0004 ZEC $0.04 + + + + + + + + 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 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Turnstile + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Turnstile + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/turnstileprogress.ui b/src/turnstileprogress.ui new file mode 100644 index 0000000..5b09ebd --- /dev/null +++ b/src/turnstileprogress.ui @@ -0,0 +1,154 @@ + + + TurnstileProgress + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + 33 + + + + + + + + 0 + 0 + + + + Please Ensure you have your wallet.dat backed up! + + + true + + + + + + + Qt::Horizontal + + + + + + + Next Transaction in 4 hours + + + + + + + 4 / 12 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Migration Progress + + + + + + + + 0 + 0 + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + + + buttonBox + accepted() + TurnstileProgress + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + TurnstileProgress + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/ui_mainwindow.h b/src/ui_mainwindow.h index c9a29ea..ac1195a 100644 --- a/src/ui_mainwindow.h +++ b/src/ui_mainwindow.h @@ -47,6 +47,8 @@ public: QAction *actionDonate; QAction *actionImport_Private_Keys; QAction *actionCheck_for_Updates; + QAction *actionTurnstile_Migration; + QAction *actionProgress; QWidget *centralWidget; QGridLayout *gridLayout_3; QTabWidget *tabWidget; @@ -159,6 +161,10 @@ public: actionImport_Private_Keys->setVisible(false); actionCheck_for_Updates = new QAction(MainWindow); actionCheck_for_Updates->setObjectName(QStringLiteral("actionCheck_for_Updates")); + actionTurnstile_Migration = new QAction(MainWindow); + actionTurnstile_Migration->setObjectName(QStringLiteral("actionTurnstile_Migration")); + actionProgress = new QAction(MainWindow); + actionProgress->setObjectName(QStringLiteral("actionProgress")); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); gridLayout_3 = new QGridLayout(centralWidget); @@ -666,6 +672,8 @@ public: menuBar->addAction(menuBalance->menuAction()); menuBar->addAction(menuHelp->menuAction()); menuBalance->addAction(actionImport_Private_Keys); + menuBalance->addAction(actionTurnstile_Migration); + menuBalance->addAction(actionProgress); menuBalance->addAction(actionSettings); menuBalance->addSeparator(); menuBalance->addAction(actionExit); @@ -690,6 +698,8 @@ public: actionDonate->setText(QApplication::translate("MainWindow", "Donate", nullptr)); actionImport_Private_Keys->setText(QApplication::translate("MainWindow", "Import Private Keys", nullptr)); actionCheck_for_Updates->setText(QApplication::translate("MainWindow", "Check github.com for Updates", nullptr)); + actionTurnstile_Migration->setText(QApplication::translate("MainWindow", "Turnstile Migration", nullptr)); + actionProgress->setText(QApplication::translate("MainWindow", "Progress", nullptr)); groupBox->setTitle(QApplication::translate("MainWindow", "Summary", nullptr)); label->setText(QApplication::translate("MainWindow", "Shielded", nullptr)); balSheilded->setText(QString()); diff --git a/src/ui_turnstile.h b/src/ui_turnstile.h new file mode 100644 index 0000000..8eb3566 --- /dev/null +++ b/src/ui_turnstile.h @@ -0,0 +1,210 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstile.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILE_H +#define UI_TURNSTILE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_Turnstile +{ +public: + QVBoxLayout *verticalLayout; + QGroupBox *groupBox; + QVBoxLayout *verticalLayout_2; + QGridLayout *gridLayout; + QLabel *msgIcon; + QLabel *label_3; + QLabel *label_2; + QLabel *label_4; + QLabel *label; + QLabel *label_5; + QSpacerItem *verticalSpacer; + QLabel *label_6; + QLabel *label_7; + QComboBox *migrateZaddList; + QComboBox *privLevel; + QLabel *label_8; + QLabel *label_9; + QComboBox *migrateTo; + QFrame *line; + QDialogButtonBox *buttonBox; + + void setupUi(QDialog *Turnstile) + { + if (Turnstile->objectName().isEmpty()) + Turnstile->setObjectName(QStringLiteral("Turnstile")); + Turnstile->resize(565, 416); + verticalLayout = new QVBoxLayout(Turnstile); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + groupBox = new QGroupBox(Turnstile); + groupBox->setObjectName(QStringLiteral("groupBox")); + verticalLayout_2 = new QVBoxLayout(groupBox); + verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); + gridLayout = new QGridLayout(); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + msgIcon = new QLabel(groupBox); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 0, 0, 1, 1); + + label_3 = new QLabel(groupBox); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); + + gridLayout->addWidget(label_3, 5, 0, 2, 1); + + label_2 = new QLabel(groupBox); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 4, 0, 1, 1); + + label_4 = new QLabel(groupBox); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_4, 5, 1, 1, 1); + + label = new QLabel(groupBox); + label->setObjectName(QStringLiteral("label")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); + label->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label, 2, 0, 1, 1); + + label_5 = new QLabel(groupBox); + label_5->setObjectName(QStringLiteral("label_5")); + sizePolicy.setHeightForWidth(label_5->sizePolicy().hasHeightForWidth()); + label_5->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_5, 6, 1, 1, 1); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 7, 0, 1, 2); + + label_6 = new QLabel(groupBox); + label_6->setObjectName(QStringLiteral("label_6")); + + gridLayout->addWidget(label_6, 5, 2, 1, 1); + + label_7 = new QLabel(groupBox); + label_7->setObjectName(QStringLiteral("label_7")); + + gridLayout->addWidget(label_7, 6, 2, 1, 1); + + migrateZaddList = new QComboBox(groupBox); + migrateZaddList->setObjectName(QStringLiteral("migrateZaddList")); + QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(migrateZaddList->sizePolicy().hasHeightForWidth()); + migrateZaddList->setSizePolicy(sizePolicy2); + migrateZaddList->setEditable(false); + + gridLayout->addWidget(migrateZaddList, 2, 1, 1, 2); + + privLevel = new QComboBox(groupBox); + privLevel->setObjectName(QStringLiteral("privLevel")); + sizePolicy2.setHeightForWidth(privLevel->sizePolicy().hasHeightForWidth()); + privLevel->setSizePolicy(sizePolicy2); + + gridLayout->addWidget(privLevel, 4, 1, 1, 2); + + label_8 = new QLabel(groupBox); + label_8->setObjectName(QStringLiteral("label_8")); + label_8->setWordWrap(true); + + gridLayout->addWidget(label_8, 0, 1, 1, 2); + + label_9 = new QLabel(groupBox); + label_9->setObjectName(QStringLiteral("label_9")); + sizePolicy1.setHeightForWidth(label_9->sizePolicy().hasHeightForWidth()); + label_9->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label_9, 3, 0, 1, 1); + + migrateTo = new QComboBox(groupBox); + migrateTo->setObjectName(QStringLiteral("migrateTo")); + + gridLayout->addWidget(migrateTo, 3, 1, 1, 2); + + line = new QFrame(groupBox); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 1, 0, 1, 3); + + + verticalLayout_2->addLayout(gridLayout); + + + verticalLayout->addWidget(groupBox); + + buttonBox = new QDialogButtonBox(Turnstile); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + verticalLayout->addWidget(buttonBox); + + + retranslateUi(Turnstile); + QObject::connect(buttonBox, SIGNAL(accepted()), Turnstile, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), Turnstile, SLOT(reject())); + + QMetaObject::connectSlotsByName(Turnstile); + } // setupUi + + void retranslateUi(QDialog *Turnstile) + { + Turnstile->setWindowTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + groupBox->setTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + msgIcon->setText(QString()); + label_3->setText(QApplication::translate("Turnstile", "Total Fees", nullptr)); + label_2->setText(QApplication::translate("Turnstile", "Privacy Level", nullptr)); + label_4->setText(QApplication::translate("Turnstile", "Miner Fee:", nullptr)); + label->setText(QApplication::translate("Turnstile", "From", nullptr)); + label_5->setText(QApplication::translate("Turnstile", "Dev Fee: ", nullptr)); + label_6->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + label_7->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + migrateZaddList->setCurrentText(QString()); + label_8->setText(QApplication::translate("Turnstile", "

Funds from Sprout z-Addresses (which start with "zc") need to be moved to the upgraded Sapling z-Addresses (which start with "zs"). The funds cannot be moved directly, but need to be sent through intermediate "transparent" addresses in privacy-preserving way.

This migration can be done automatically for you.

", nullptr)); + label_9->setText(QApplication::translate("Turnstile", "To", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class Turnstile: public Ui_Turnstile {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILE_H diff --git a/src/ui_turnstileprogress.h b/src/ui_turnstileprogress.h new file mode 100644 index 0000000..2d34909 --- /dev/null +++ b/src/ui_turnstileprogress.h @@ -0,0 +1,141 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstileprogress.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILEPROGRESS_H +#define UI_TURNSTILEPROGRESS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_TurnstileProgress +{ +public: + QGridLayout *gridLayout; + QProgressBar *progressBar; + QLabel *label_4; + QFrame *line; + QLabel *label; + QLabel *label_3; + QLabel *label_2; + QLabel *msgIcon; + QDialogButtonBox *buttonBox; + QSpacerItem *verticalSpacer; + QFrame *line_2; + + void setupUi(QDialog *TurnstileProgress) + { + if (TurnstileProgress->objectName().isEmpty()) + TurnstileProgress->setObjectName(QStringLiteral("TurnstileProgress")); + TurnstileProgress->resize(400, 300); + gridLayout = new QGridLayout(TurnstileProgress); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + progressBar = new QProgressBar(TurnstileProgress); + progressBar->setObjectName(QStringLiteral("progressBar")); + progressBar->setValue(33); + + gridLayout->addWidget(progressBar, 3, 0, 1, 3); + + label_4 = new QLabel(TurnstileProgress); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + label_4->setWordWrap(true); + + gridLayout->addWidget(label_4, 7, 1, 1, 2); + + line = new QFrame(TurnstileProgress); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 4, 0, 1, 3); + + label = new QLabel(TurnstileProgress); + label->setObjectName(QStringLiteral("label")); + + gridLayout->addWidget(label, 5, 0, 1, 3); + + label_3 = new QLabel(TurnstileProgress); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + + gridLayout->addWidget(label_3, 2, 2, 1, 1); + + label_2 = new QLabel(TurnstileProgress); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 2, 0, 1, 2); + + msgIcon = new QLabel(TurnstileProgress); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(msgIcon->sizePolicy().hasHeightForWidth()); + msgIcon->setSizePolicy(sizePolicy1); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 7, 0, 1, 1); + + buttonBox = new QDialogButtonBox(TurnstileProgress); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + gridLayout->addWidget(buttonBox, 9, 0, 1, 3); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 6, 0, 1, 3); + + line_2 = new QFrame(TurnstileProgress); + line_2->setObjectName(QStringLiteral("line_2")); + line_2->setFrameShape(QFrame::HLine); + line_2->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line_2, 8, 0, 1, 3); + + + retranslateUi(TurnstileProgress); + QObject::connect(buttonBox, SIGNAL(accepted()), TurnstileProgress, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), TurnstileProgress, SLOT(reject())); + + QMetaObject::connectSlotsByName(TurnstileProgress); + } // setupUi + + void retranslateUi(QDialog *TurnstileProgress) + { + TurnstileProgress->setWindowTitle(QApplication::translate("TurnstileProgress", "Dialog", nullptr)); + label_4->setText(QApplication::translate("TurnstileProgress", "Please Ensure you have your wallet.dat backed up!", nullptr)); + label->setText(QApplication::translate("TurnstileProgress", "Next Transaction in 4 hours", nullptr)); + label_3->setText(QApplication::translate("TurnstileProgress", "4 / 12", nullptr)); + label_2->setText(QApplication::translate("TurnstileProgress", "Migration Progress", nullptr)); + msgIcon->setText(QApplication::translate("TurnstileProgress", "TextLabel", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class TurnstileProgress: public Ui_TurnstileProgress {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILEPROGRESS_H diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index 5c913e3..497a23c 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -71,7 +71,9 @@ FORMS += \ src/mainwindow.ui \ src/settings.ui \ src/about.ui \ - src/confirm.ui + src/confirm.ui \ + src/turnstile.ui \ + src/turnstileprogress.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin From be26b2a8e3fe49ebce9323af17b9be4815392196 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 22 Oct 2018 22:10:52 -0700 Subject: [PATCH 04/10] Turnstile prototype --- src/mainwindow.cpp | 35 ++++++ src/mainwindow.ui | 12 ++ src/turnstile.ui | 229 +++++++++++++++++++++++++++++++++++++ src/turnstileprogress.ui | 154 +++++++++++++++++++++++++ src/ui_mainwindow.h | 10 ++ src/ui_turnstile.h | 210 ++++++++++++++++++++++++++++++++++ src/ui_turnstileprogress.h | 141 +++++++++++++++++++++++ zec-qt-wallet.pro | 4 +- 8 files changed, 794 insertions(+), 1 deletion(-) create mode 100644 src/turnstile.ui create mode 100644 src/turnstileprogress.ui create mode 100644 src/ui_turnstile.h create mode 100644 src/ui_turnstileprogress.h diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2606f6d..d03c0a6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,12 +2,15 @@ #include "ui_mainwindow.h" #include "ui_about.h" #include "ui_settings.h" +#include "ui_turnstile.h" +#include "ui_turnstileprogress.h" #include "rpc.h" #include "balancestablemodel.h" #include "settings.h" #include "utils.h" #include "senttxstore.h" + #include "precompiled.h" using json = nlohmann::json; @@ -24,6 +27,38 @@ MainWindow::MainWindow(QWidget *parent) : // Settings editor setupSettingsModal(); + // Turnstile migration + QObject::connect(ui->actionTurnstile_Migration, &QAction::triggered, [=] () { + Ui_Turnstile turnstile; + QDialog d(this); + turnstile.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); + turnstile.msgIcon->setPixmap(icon.pixmap(64, 64)); + + turnstile.migrateZaddList->addItem("All Sprout z-Addrs"); + turnstile.migrateTo->addItem("zs1gv64eu0v2wx7raxqxlmj354y9ycznwaau9kduljzczxztvs4qcl00kn2sjxtejvrxnkucw5xx9u"); + turnstile.privLevel->addItem("Good - 3 tx over 3 days"); + turnstile.privLevel->addItem("Excellent - 5 tx over 5 days"); + turnstile.privLevel->addItem("Paranoid - 10 tx over 7 days"); + + turnstile.buttonBox->button(QDialogButtonBox::Ok)->setText("Start"); + + d.exec(); + }); + + QObject::connect(ui->actionProgress, &QAction::triggered, [=] () { + Ui_TurnstileProgress progress; + QDialog d(this); + progress.setupUi(&d); + + QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); + progress.msgIcon->setPixmap(icon.pixmap(64, 64)); + + progress.buttonBox->button(QDialogButtonBox::Cancel)->setText("Abort"); + d.exec(); + }); + // Set up exit action QObject::connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 4baf922..9e408c4 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -720,6 +720,8 @@ File + + @@ -769,6 +771,16 @@ Check github.com for Updates + + + Turnstile Migration + + + + + Progress + + diff --git a/src/turnstile.ui b/src/turnstile.ui new file mode 100644 index 0000000..a12af05 --- /dev/null +++ b/src/turnstile.ui @@ -0,0 +1,229 @@ + + + Turnstile + + + + 0 + 0 + 565 + 416 + + + + Turnstile Migration + + + + + + Turnstile Migration + + + + + + + + + + + Qt::AlignCenter + + + + + + + Total Fees + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Privacy Level + + + + + + + + 0 + 0 + + + + Miner Fee: + + + + + + + + 0 + 0 + + + + From + + + + + + + + 0 + 0 + + + + Dev Fee: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0.0004 ZEC $0.04 + + + + + + + 0.0004 ZEC $0.04 + + + + + + + + 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 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Turnstile + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Turnstile + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/turnstileprogress.ui b/src/turnstileprogress.ui new file mode 100644 index 0000000..5b09ebd --- /dev/null +++ b/src/turnstileprogress.ui @@ -0,0 +1,154 @@ + + + TurnstileProgress + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + 33 + + + + + + + + 0 + 0 + + + + Please Ensure you have your wallet.dat backed up! + + + true + + + + + + + Qt::Horizontal + + + + + + + Next Transaction in 4 hours + + + + + + + 4 / 12 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Migration Progress + + + + + + + + 0 + 0 + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + + + buttonBox + accepted() + TurnstileProgress + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + TurnstileProgress + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/ui_mainwindow.h b/src/ui_mainwindow.h index c9a29ea..ac1195a 100644 --- a/src/ui_mainwindow.h +++ b/src/ui_mainwindow.h @@ -47,6 +47,8 @@ public: QAction *actionDonate; QAction *actionImport_Private_Keys; QAction *actionCheck_for_Updates; + QAction *actionTurnstile_Migration; + QAction *actionProgress; QWidget *centralWidget; QGridLayout *gridLayout_3; QTabWidget *tabWidget; @@ -159,6 +161,10 @@ public: actionImport_Private_Keys->setVisible(false); actionCheck_for_Updates = new QAction(MainWindow); actionCheck_for_Updates->setObjectName(QStringLiteral("actionCheck_for_Updates")); + actionTurnstile_Migration = new QAction(MainWindow); + actionTurnstile_Migration->setObjectName(QStringLiteral("actionTurnstile_Migration")); + actionProgress = new QAction(MainWindow); + actionProgress->setObjectName(QStringLiteral("actionProgress")); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); gridLayout_3 = new QGridLayout(centralWidget); @@ -666,6 +672,8 @@ public: menuBar->addAction(menuBalance->menuAction()); menuBar->addAction(menuHelp->menuAction()); menuBalance->addAction(actionImport_Private_Keys); + menuBalance->addAction(actionTurnstile_Migration); + menuBalance->addAction(actionProgress); menuBalance->addAction(actionSettings); menuBalance->addSeparator(); menuBalance->addAction(actionExit); @@ -690,6 +698,8 @@ public: actionDonate->setText(QApplication::translate("MainWindow", "Donate", nullptr)); actionImport_Private_Keys->setText(QApplication::translate("MainWindow", "Import Private Keys", nullptr)); actionCheck_for_Updates->setText(QApplication::translate("MainWindow", "Check github.com for Updates", nullptr)); + actionTurnstile_Migration->setText(QApplication::translate("MainWindow", "Turnstile Migration", nullptr)); + actionProgress->setText(QApplication::translate("MainWindow", "Progress", nullptr)); groupBox->setTitle(QApplication::translate("MainWindow", "Summary", nullptr)); label->setText(QApplication::translate("MainWindow", "Shielded", nullptr)); balSheilded->setText(QString()); diff --git a/src/ui_turnstile.h b/src/ui_turnstile.h new file mode 100644 index 0000000..8eb3566 --- /dev/null +++ b/src/ui_turnstile.h @@ -0,0 +1,210 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstile.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILE_H +#define UI_TURNSTILE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_Turnstile +{ +public: + QVBoxLayout *verticalLayout; + QGroupBox *groupBox; + QVBoxLayout *verticalLayout_2; + QGridLayout *gridLayout; + QLabel *msgIcon; + QLabel *label_3; + QLabel *label_2; + QLabel *label_4; + QLabel *label; + QLabel *label_5; + QSpacerItem *verticalSpacer; + QLabel *label_6; + QLabel *label_7; + QComboBox *migrateZaddList; + QComboBox *privLevel; + QLabel *label_8; + QLabel *label_9; + QComboBox *migrateTo; + QFrame *line; + QDialogButtonBox *buttonBox; + + void setupUi(QDialog *Turnstile) + { + if (Turnstile->objectName().isEmpty()) + Turnstile->setObjectName(QStringLiteral("Turnstile")); + Turnstile->resize(565, 416); + verticalLayout = new QVBoxLayout(Turnstile); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + groupBox = new QGroupBox(Turnstile); + groupBox->setObjectName(QStringLiteral("groupBox")); + verticalLayout_2 = new QVBoxLayout(groupBox); + verticalLayout_2->setObjectName(QStringLiteral("verticalLayout_2")); + gridLayout = new QGridLayout(); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + msgIcon = new QLabel(groupBox); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 0, 0, 1, 1); + + label_3 = new QLabel(groupBox); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); + + gridLayout->addWidget(label_3, 5, 0, 2, 1); + + label_2 = new QLabel(groupBox); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 4, 0, 1, 1); + + label_4 = new QLabel(groupBox); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_4, 5, 1, 1, 1); + + label = new QLabel(groupBox); + label->setObjectName(QStringLiteral("label")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); + label->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label, 2, 0, 1, 1); + + label_5 = new QLabel(groupBox); + label_5->setObjectName(QStringLiteral("label_5")); + sizePolicy.setHeightForWidth(label_5->sizePolicy().hasHeightForWidth()); + label_5->setSizePolicy(sizePolicy); + + gridLayout->addWidget(label_5, 6, 1, 1, 1); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 7, 0, 1, 2); + + label_6 = new QLabel(groupBox); + label_6->setObjectName(QStringLiteral("label_6")); + + gridLayout->addWidget(label_6, 5, 2, 1, 1); + + label_7 = new QLabel(groupBox); + label_7->setObjectName(QStringLiteral("label_7")); + + gridLayout->addWidget(label_7, 6, 2, 1, 1); + + migrateZaddList = new QComboBox(groupBox); + migrateZaddList->setObjectName(QStringLiteral("migrateZaddList")); + QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Fixed); + sizePolicy2.setHorizontalStretch(0); + sizePolicy2.setVerticalStretch(0); + sizePolicy2.setHeightForWidth(migrateZaddList->sizePolicy().hasHeightForWidth()); + migrateZaddList->setSizePolicy(sizePolicy2); + migrateZaddList->setEditable(false); + + gridLayout->addWidget(migrateZaddList, 2, 1, 1, 2); + + privLevel = new QComboBox(groupBox); + privLevel->setObjectName(QStringLiteral("privLevel")); + sizePolicy2.setHeightForWidth(privLevel->sizePolicy().hasHeightForWidth()); + privLevel->setSizePolicy(sizePolicy2); + + gridLayout->addWidget(privLevel, 4, 1, 1, 2); + + label_8 = new QLabel(groupBox); + label_8->setObjectName(QStringLiteral("label_8")); + label_8->setWordWrap(true); + + gridLayout->addWidget(label_8, 0, 1, 1, 2); + + label_9 = new QLabel(groupBox); + label_9->setObjectName(QStringLiteral("label_9")); + sizePolicy1.setHeightForWidth(label_9->sizePolicy().hasHeightForWidth()); + label_9->setSizePolicy(sizePolicy1); + + gridLayout->addWidget(label_9, 3, 0, 1, 1); + + migrateTo = new QComboBox(groupBox); + migrateTo->setObjectName(QStringLiteral("migrateTo")); + + gridLayout->addWidget(migrateTo, 3, 1, 1, 2); + + line = new QFrame(groupBox); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 1, 0, 1, 3); + + + verticalLayout_2->addLayout(gridLayout); + + + verticalLayout->addWidget(groupBox); + + buttonBox = new QDialogButtonBox(Turnstile); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + verticalLayout->addWidget(buttonBox); + + + retranslateUi(Turnstile); + QObject::connect(buttonBox, SIGNAL(accepted()), Turnstile, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), Turnstile, SLOT(reject())); + + QMetaObject::connectSlotsByName(Turnstile); + } // setupUi + + void retranslateUi(QDialog *Turnstile) + { + Turnstile->setWindowTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + groupBox->setTitle(QApplication::translate("Turnstile", "Turnstile Migration", nullptr)); + msgIcon->setText(QString()); + label_3->setText(QApplication::translate("Turnstile", "Total Fees", nullptr)); + label_2->setText(QApplication::translate("Turnstile", "Privacy Level", nullptr)); + label_4->setText(QApplication::translate("Turnstile", "Miner Fee:", nullptr)); + label->setText(QApplication::translate("Turnstile", "From", nullptr)); + label_5->setText(QApplication::translate("Turnstile", "Dev Fee: ", nullptr)); + label_6->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + label_7->setText(QApplication::translate("Turnstile", "0.0004 ZEC $0.04", nullptr)); + migrateZaddList->setCurrentText(QString()); + label_8->setText(QApplication::translate("Turnstile", "

Funds from Sprout z-Addresses (which start with "zc") need to be moved to the upgraded Sapling z-Addresses (which start with "zs"). The funds cannot be moved directly, but need to be sent through intermediate "transparent" addresses in privacy-preserving way.

This migration can be done automatically for you.

", nullptr)); + label_9->setText(QApplication::translate("Turnstile", "To", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class Turnstile: public Ui_Turnstile {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILE_H diff --git a/src/ui_turnstileprogress.h b/src/ui_turnstileprogress.h new file mode 100644 index 0000000..2d34909 --- /dev/null +++ b/src/ui_turnstileprogress.h @@ -0,0 +1,141 @@ +/******************************************************************************** +** Form generated from reading UI file 'turnstileprogress.ui' +** +** Created by: Qt User Interface Compiler version 5.11.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_TURNSTILEPROGRESS_H +#define UI_TURNSTILEPROGRESS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_TurnstileProgress +{ +public: + QGridLayout *gridLayout; + QProgressBar *progressBar; + QLabel *label_4; + QFrame *line; + QLabel *label; + QLabel *label_3; + QLabel *label_2; + QLabel *msgIcon; + QDialogButtonBox *buttonBox; + QSpacerItem *verticalSpacer; + QFrame *line_2; + + void setupUi(QDialog *TurnstileProgress) + { + if (TurnstileProgress->objectName().isEmpty()) + TurnstileProgress->setObjectName(QStringLiteral("TurnstileProgress")); + TurnstileProgress->resize(400, 300); + gridLayout = new QGridLayout(TurnstileProgress); + gridLayout->setObjectName(QStringLiteral("gridLayout")); + progressBar = new QProgressBar(TurnstileProgress); + progressBar->setObjectName(QStringLiteral("progressBar")); + progressBar->setValue(33); + + gridLayout->addWidget(progressBar, 3, 0, 1, 3); + + label_4 = new QLabel(TurnstileProgress); + label_4->setObjectName(QStringLiteral("label_4")); + QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(label_4->sizePolicy().hasHeightForWidth()); + label_4->setSizePolicy(sizePolicy); + label_4->setWordWrap(true); + + gridLayout->addWidget(label_4, 7, 1, 1, 2); + + line = new QFrame(TurnstileProgress); + line->setObjectName(QStringLiteral("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line, 4, 0, 1, 3); + + label = new QLabel(TurnstileProgress); + label->setObjectName(QStringLiteral("label")); + + gridLayout->addWidget(label, 5, 0, 1, 3); + + label_3 = new QLabel(TurnstileProgress); + label_3->setObjectName(QStringLiteral("label_3")); + label_3->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + + gridLayout->addWidget(label_3, 2, 2, 1, 1); + + label_2 = new QLabel(TurnstileProgress); + label_2->setObjectName(QStringLiteral("label_2")); + + gridLayout->addWidget(label_2, 2, 0, 1, 2); + + msgIcon = new QLabel(TurnstileProgress); + msgIcon->setObjectName(QStringLiteral("msgIcon")); + QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(msgIcon->sizePolicy().hasHeightForWidth()); + msgIcon->setSizePolicy(sizePolicy1); + msgIcon->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(msgIcon, 7, 0, 1, 1); + + buttonBox = new QDialogButtonBox(TurnstileProgress); + buttonBox->setObjectName(QStringLiteral("buttonBox")); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + + gridLayout->addWidget(buttonBox, 9, 0, 1, 3); + + verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + + gridLayout->addItem(verticalSpacer, 6, 0, 1, 3); + + line_2 = new QFrame(TurnstileProgress); + line_2->setObjectName(QStringLiteral("line_2")); + line_2->setFrameShape(QFrame::HLine); + line_2->setFrameShadow(QFrame::Sunken); + + gridLayout->addWidget(line_2, 8, 0, 1, 3); + + + retranslateUi(TurnstileProgress); + QObject::connect(buttonBox, SIGNAL(accepted()), TurnstileProgress, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), TurnstileProgress, SLOT(reject())); + + QMetaObject::connectSlotsByName(TurnstileProgress); + } // setupUi + + void retranslateUi(QDialog *TurnstileProgress) + { + TurnstileProgress->setWindowTitle(QApplication::translate("TurnstileProgress", "Dialog", nullptr)); + label_4->setText(QApplication::translate("TurnstileProgress", "Please Ensure you have your wallet.dat backed up!", nullptr)); + label->setText(QApplication::translate("TurnstileProgress", "Next Transaction in 4 hours", nullptr)); + label_3->setText(QApplication::translate("TurnstileProgress", "4 / 12", nullptr)); + label_2->setText(QApplication::translate("TurnstileProgress", "Migration Progress", nullptr)); + msgIcon->setText(QApplication::translate("TurnstileProgress", "TextLabel", nullptr)); + } // retranslateUi + +}; + +namespace Ui { + class TurnstileProgress: public Ui_TurnstileProgress {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_TURNSTILEPROGRESS_H diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index 5c913e3..497a23c 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -71,7 +71,9 @@ FORMS += \ src/mainwindow.ui \ src/settings.ui \ src/about.ui \ - src/confirm.ui + src/confirm.ui \ + src/turnstile.ui \ + src/turnstileprogress.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin From 444e16e97311e5fb025b7e3970922a4c8bd95749 Mon Sep 17 00:00:00 2001 From: adityapk00 Date: Wed, 24 Oct 2018 21:06:03 -0700 Subject: [PATCH 05/10] intermediate checkin --- src/main.cpp | 8 ++++++++ src/precompiled.h | 2 ++ src/turnstile.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/turnstile.h | 11 +++++++++++ zec-qt-wallet.pro | 2 ++ 5 files changed, 60 insertions(+) create mode 100644 src/turnstile.cpp create mode 100644 src/turnstile.h diff --git a/src/main.cpp b/src/main.cpp index 76b6873..f96df19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ #include "mainwindow.h" #include "settings.h" +#include "turnstile.h" + #include "precompiled.h" int main(int argc, char *argv[]) @@ -16,6 +18,8 @@ int main(int argc, char *argv[]) qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false)); #endif + std::srand(std::time(nullptr)); + QCoreApplication::setOrganizationName("zec-qt-wallet-org"); QCoreApplication::setApplicationName("zec-qt-wallet"); @@ -24,6 +28,10 @@ int main(int argc, char *argv[]) MainWindow w; w.setWindowTitle("zec-qt-wallet v" + QString(APP_VERSION)); w.show(); + + // Temp + Turnstile t; + qDebug() << t.splitAmount(1245.2294371, 3); return QApplication::exec(); } diff --git a/src/precompiled.h b/src/precompiled.h index c3e837b..976fba1 100644 --- a/src/precompiled.h +++ b/src/precompiled.h @@ -2,6 +2,8 @@ /* Add C++ includes here */ #include +#include +#include #include #include diff --git a/src/turnstile.cpp b/src/turnstile.cpp new file mode 100644 index 0000000..c442d70 --- /dev/null +++ b/src/turnstile.cpp @@ -0,0 +1,37 @@ +#include "precompiled.h" +#include "turnstile.h" + + +Turnstile::Turnstile() { +} + + +Turnstile::~Turnstile() { +} + +QList Turnstile::splitAmount(double amount, int parts) { + QList amounts; + fillAmounts(amounts, amount, parts); + + // Ensure they all add up! + double sumofparts = 0; + for (auto a : amounts) { + sumofparts += a.toDouble(); + } + + Q_ASSERT(sumofparts == amount); + return amounts; +} + +void Turnstile::fillAmounts(QList& amounts, double amount, int count) { + if (count == 1 || amount < 1) { + amounts.push_back(QString::number(amount, 'g', 8)); + return; + } + + // Get a random amount off the amount and call recursively. + auto curAmount = std::rand() % (int)std::floor(amount); + amounts.push_back(QString::number(curAmount, 'g', 8)); + + fillAmounts(amounts, amount - curAmount, count - 1); +} \ No newline at end of file diff --git a/src/turnstile.h b/src/turnstile.h new file mode 100644 index 0000000..0da7098 --- /dev/null +++ b/src/turnstile.h @@ -0,0 +1,11 @@ +#pragma once +class Turnstile +{ +public: + Turnstile(); + ~Turnstile(); + + QList Turnstile::splitAmount(double amount, int parts); + void fillAmounts(QList& amounts, double amount, int count); +}; + diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index 497a23c..7ae1f78 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -50,6 +50,7 @@ SOURCES += \ src/sendtab.cpp \ src/senttxstore.cpp \ src/txtablemodel.cpp \ + src/turnstile.cpp \ src/utils.cpp HEADERS += \ @@ -65,6 +66,7 @@ HEADERS += \ src/settings.h \ src/txtablemodel.h \ src/senttxstore.h \ + src/turnstile.h \ src/utils.h FORMS += \ From bdeefef95ae97e3fd958ec5ed62a5856a146f949 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 24 Oct 2018 22:28:55 -0700 Subject: [PATCH 06/10] Split up amounts --- src/main.cpp | 6 +++++- src/mainwindow.cpp | 1 - src/precompiled.h | 1 + src/turnstile.cpp | 40 ++++++++++++++++++++++++++++++++-------- src/turnstile.h | 11 ++++++++--- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f96df19..b73e119 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,11 @@ int main(int argc, char *argv[]) // Temp Turnstile t; - qDebug() << t.splitAmount(1245.2294371, 3); + double amt = 2329127.99999999; + qDebug() << QString::number(amt, 'f', 8) << ":"; + for (auto a : t.splitAmount(amt, 3)) { + qDebug() << QString::number(a, 'f', 8); + } return QApplication::exec(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d03c0a6..9816d6a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -10,7 +10,6 @@ #include "utils.h" #include "senttxstore.h" - #include "precompiled.h" using json = nlohmann::json; diff --git a/src/precompiled.h b/src/precompiled.h index 976fba1..552226d 100644 --- a/src/precompiled.h +++ b/src/precompiled.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/src/turnstile.cpp b/src/turnstile.cpp index c442d70..bb15260 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -1,6 +1,6 @@ -#include "precompiled.h" #include "turnstile.h" +#include "utils.h" Turnstile::Turnstile() { } @@ -9,29 +9,53 @@ Turnstile::Turnstile() { Turnstile::~Turnstile() { } -QList Turnstile::splitAmount(double amount, int parts) { - QList amounts; +QList Turnstile::splitAmount(double amount, int parts) { + QList amounts; fillAmounts(amounts, amount, parts); // Ensure they all add up! double sumofparts = 0; for (auto a : amounts) { - sumofparts += a.toDouble(); + sumofparts += a; } Q_ASSERT(sumofparts == amount); return amounts; } -void Turnstile::fillAmounts(QList& amounts, double amount, int count) { +void Turnstile::fillAmounts(QList& amounts, double amount, int count) { if (count == 1 || amount < 1) { - amounts.push_back(QString::number(amount, 'g', 8)); + // Split the chaff. + // Chaff is all amounts lesser than 0.0001 ZEC. The chaff will be added to the + // dev fee, and is done so to protect privacy. + + // Get the rounded value to 4 decimal places (approx $0.01) + double actual = std::floor(amount * 10000) / 10000; + + // Reduce the Dev Tx fee from the amount + actual = actual - 0.0001; //Utils::getDevFee(); + + // Calculate the chaff. + double chaff = amount - actual; + + amounts.push_back(actual); + if (chaff > 0.00000001) // zcash is split down to 8 decimal places + amounts.push_back(chaff); return; } - // Get a random amount off the amount and call recursively. + // Get a random amount off the amount (between half and full) and call recursively. auto curAmount = std::rand() % (int)std::floor(amount); - amounts.push_back(QString::number(curAmount, 'g', 8)); + + // Try to round it off + if (curAmount > 1000) { + curAmount = std::floor(curAmount / 100) * 100; + } else if (curAmount > 100) { + curAmount = std::floor(curAmount / 10) * 10; + } + + if (curAmount > 0) + amounts.push_back(curAmount); fillAmounts(amounts, amount - curAmount, count - 1); } \ No newline at end of file diff --git a/src/turnstile.h b/src/turnstile.h index 0da7098..7a4bac7 100644 --- a/src/turnstile.h +++ b/src/turnstile.h @@ -1,11 +1,16 @@ -#pragma once +#ifndef TURNSTILE_H +#define TURNSTILE_H + +#include "precompiled.h" + class Turnstile { public: Turnstile(); ~Turnstile(); - QList Turnstile::splitAmount(double amount, int parts); - void fillAmounts(QList& amounts, double amount, int count); + QList splitAmount(double amount, int parts); + void fillAmounts(QList& amounts, double amount, int count); }; +#endif \ No newline at end of file From b9b99aea9392a05fdf5e28049bbce5fa0fcd981b Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 24 Oct 2018 22:33:45 -0700 Subject: [PATCH 07/10] Account for tx fees --- src/turnstile.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/turnstile.cpp b/src/turnstile.cpp index bb15260..349db59 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -35,6 +35,9 @@ void Turnstile::fillAmounts(QList& amounts, double amount, int count) { // Reduce the Dev Tx fee from the amount actual = actual - 0.0001; //Utils::getDevFee(); + // Also account for the fees needed to send all these transactions + actual = actual - (Utils::getMinerFee() * (amounts.size() + 1)); + // Calculate the chaff. double chaff = amount - actual; From ca9fcd754dd2d91f6cf241472db234d09d0bfe5b Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 24 Oct 2018 22:44:45 -0700 Subject: [PATCH 08/10] Add min --- src/turnstile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/turnstile.cpp b/src/turnstile.cpp index 349db59..a4f8f94 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -11,6 +11,10 @@ Turnstile::~Turnstile() { QList Turnstile::splitAmount(double amount, int parts) { QList amounts; + // Need at least 0.0004 ZEC for this + if (amount < 0.0004) + return amounts; + fillAmounts(amounts, amount, parts); // Ensure they all add up! From e84a24c5496ad426bec31aa4ff5ac0139923c778 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 25 Oct 2018 09:44:40 -0700 Subject: [PATCH 09/10] minor --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b73e119..96581a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) // Temp Turnstile t; - double amt = 2329127.99999999; + double amt = 0.0003; qDebug() << QString::number(amt, 'f', 8) << ":"; for (auto a : t.splitAmount(amt, 3)) { qDebug() << QString::number(a, 'f', 8); From 66b09aa344178c45ff91ddb4b5c72772a33653db Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 25 Oct 2018 11:52:02 -0700 Subject: [PATCH 10/10] create migration plan --- README.md | 4 +- src/main.cpp | 8 ---- src/rpc.cpp | 61 ++++-------------------- src/rpc.h | 54 +++++++++++++++++++-- src/turnstile.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++++-- src/turnstile.h | 23 ++++++++- zec-qt-wallet.pro | 2 +- 7 files changed, 198 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index b29c990..4f13a91 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Head over to the releases page and grab the latest binary. https://github.com/ad ### Linux Extract and run the binary ``` -tar -xvf zec-qt-wallet-v0.2.2.tar.gz -./zec-qt-wallet-v0.2.2/zec-qt-wallet +tar -xvf zec-qt-wallet-v0.2.3.tar.gz +./zec-qt-wallet-v0.2.3/zec-qt-wallet ``` ### Windows diff --git a/src/main.cpp b/src/main.cpp index 96581a4..c86c2af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,14 +28,6 @@ int main(int argc, char *argv[]) MainWindow w; w.setWindowTitle("zec-qt-wallet v" + QString(APP_VERSION)); w.show(); - - // Temp - Turnstile t; - double amt = 0.0003; - qDebug() << QString::number(amt, 'f', 8) << ":"; - for (auto a : t.splitAmount(amt, 3)) { - qDebug() << QString::number(a, 'f', 8); - } return QApplication::exec(); } diff --git a/src/rpc.cpp b/src/rpc.cpp index 5dce998..c70a6f1 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -2,6 +2,7 @@ #include "utils.h" #include "settings.h" #include "senttxstore.h" +#include "turnstile.h" using json = nlohmann::json; @@ -46,6 +47,7 @@ RPC::RPC(QNetworkAccessManager* client, MainWindow* main) { }); // Start at every 10s. When an operation is pending, this will change to every second txTimer->start(Utils::updateSpeed); + } RPC::~RPC() { @@ -284,54 +286,6 @@ void RPC::handleTxError(const QString& error) { msg.exec(); } - -void RPC::getBatchRPC( - const QList& payloads, - std::function payloadGenerator, - std::function*)> cb) -{ - auto responses = new QMap(); // zAddr -> list of responses for each call. - int totalSize = payloads.size(); - - for (auto item: payloads) { - json payload = payloadGenerator(item); - - QNetworkReply *reply = restclient->post(request, QByteArray::fromStdString(payload.dump())); - - QObject::connect(reply, &QNetworkReply::finished, [=] { - reply->deleteLater(); - - auto all = reply->readAll(); - auto parsed = json::parse(all.toStdString(), nullptr, false); - - if (reply->error() != QNetworkReply::NoError) { - qDebug() << QString::fromStdString(parsed.dump()); - qDebug() << reply->errorString(); - - (*responses)[item] = json::object(); // Empty object - } else { - if (parsed.is_discarded()) { - (*responses)[item] = json::object(); // Empty object - } else { - (*responses)[item] = parsed["result"]; - } - } - }); - } - - auto waitTimer = new QTimer(main); - QObject::connect(waitTimer, &QTimer::timeout, [=]() { - if (responses->size() == totalSize) { - waitTimer->stop(); - - cb(responses); - - waitTimer->deleteLater(); - } - }); - waitTimer->start(100); -} - // Refresh received z txs by calling z_listreceivedbyaddress/gettransaction void RPC::refreshReceivedZTrans(QList zaddrs) { @@ -349,7 +303,7 @@ void RPC::refreshReceivedZTrans(QList zaddrs) { // and each z-Addr can have multiple received txs. // 1. For each z-Addr, get list of received txs - getBatchRPC(zaddrs, + getBatchRPC(zaddrs, [=] (QString zaddr) { json payload = { {"jsonrpc", "1.0"}, @@ -373,7 +327,7 @@ void RPC::refreshReceivedZTrans(QList zaddrs) { } // 2. For all txids, go and get the details of that txid. - getBatchRPC(txids.toList(), + getBatchRPC(txids.toList(), [=] (QString txid) { json payload = { {"jsonrpc", "1.0"}, @@ -507,6 +461,11 @@ void RPC::refreshAddresses() { // Function to create the data model and update the views, used below. void RPC::updateUI(bool anyUnconfirmed) { + + // Temp + Turnstile t(this); + t.planMigration(zaddresses->at(1), zaddresses->at(0)); + ui->unconfirmedWarning->setVisible(anyUnconfirmed); // Update balances model data, which will update the table too @@ -624,7 +583,7 @@ void RPC::refreshSentZTrans() { } // Look up all the txids to get the confirmation count for them. - getBatchRPC(txids, + getBatchRPC(txids, [=] (QString txid) { json payload = { {"jsonrpc", "1.0"}, diff --git a/src/rpc.h b/src/rpc.h index bdb903b..1bbd6fd 100644 --- a/src/rpc.h +++ b/src/rpc.h @@ -46,6 +46,55 @@ public: void newZaddr (bool sapling, const std::function& cb); void newTaddr (const std::function& cb); + // Batch method. Note: Because of the template, it has to be in the header file. + template + void getBatchRPC(const QList& payloads, + std::function payloadGenerator, + std::function*)> cb) { + auto responses = new QMap(); // zAddr -> list of responses for each call. + int totalSize = payloads.size(); + + for (auto item: payloads) { + json payload = payloadGenerator(item); + + QNetworkReply *reply = restclient->post(request, QByteArray::fromStdString(payload.dump())); + + QObject::connect(reply, &QNetworkReply::finished, [=] { + reply->deleteLater(); + + auto all = reply->readAll(); + auto parsed = json::parse(all.toStdString(), nullptr, false); + + if (reply->error() != QNetworkReply::NoError) { + qDebug() << QString::fromStdString(parsed.dump()); + qDebug() << reply->errorString(); + + (*responses)[item] = json::object(); // Empty object + } else { + if (parsed.is_discarded()) { + (*responses)[item] = json::object(); // Empty object + } else { + (*responses)[item] = parsed["result"]; + } + } + }); + } + + auto waitTimer = new QTimer(main); + QObject::connect(waitTimer, &QTimer::timeout, [=]() { + if (responses->size() == totalSize) { + waitTimer->stop(); + + cb(responses); + + waitTimer->deleteLater(); + } + }); + waitTimer->start(100); + } + + + private: void doRPC (const json& payload, const std::function& cb); void doSendRPC (const json& payload, const std::function& cb); @@ -71,11 +120,6 @@ private: void handleConnectionError (const QString& error); void handleTxError (const QString& error); - // Batch - void getBatchRPC(const QList& payloads, - std::function payloadGenerator, - std::function*)> cb); - QNetworkAccessManager* restclient; QNetworkRequest request; diff --git a/src/turnstile.cpp b/src/turnstile.cpp index a4f8f94..9385ba8 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -1,14 +1,125 @@ #include "turnstile.h" - +#include "rpc.h" #include "utils.h" +#include "settings.h" -Turnstile::Turnstile() { +#include "precompiled.h" + +using json = nlohmann::json; + +Turnstile::Turnstile(RPC* _rpc) { + this->rpc = _rpc; } - Turnstile::~Turnstile() { } +QString Turnstile::writeableFile() { + auto filename = QStringLiteral("turnstilemigrationplan.dat"); + + auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); + if (!dir.exists()) + QDir().mkpath(dir.absolutePath()); + + if (Settings::getInstance()->isTestnet()) { + return dir.filePath("testnet-" % filename); + } else { + return dir.filePath(filename); + } +} + +// Data stream write/read methods for migration items +QDataStream &operator<<(QDataStream& ds, const TurnstileMigrationItem& item) { + return ds << "v1" << item.fromAddr << item.intTAddr + << item.destAddr << item.amount << item.blockNumber << item.chaff; +} + +QDataStream &operator>>(QDataStream& ds, TurnstileMigrationItem& item) { + QString version; + return ds >> version >> item.fromAddr >> item.intTAddr + >> item.destAddr >> item.amount >> item.blockNumber >> item.chaff; +} + +void Turnstile::writeMigrationPlan(QList plan) { + QFile file(writeableFile()); + file.open(QIODevice::WriteOnly); + QDataStream out(&file); // we will serialize the data into the file + out << plan; +} + +QList Turnstile::readMigrationPlan() { + QFile file(writeableFile()); + + QList plan; + if (!file.exists()) return plan; + + file.open(QIODevice::ReadOnly); + QDataStream in(&file); // read the data serialized from the file + in >> plan; + + return plan; +} + +void Turnstile::planMigration(QString zaddr, QString destAddr) { + // First, get the balance and split up the amounts + auto bal = rpc->getAllBalances()->value(zaddr); + auto splits = splitAmount(bal+2354, 5); + + // Then, generate an intermediate t-Address for each part using getBatchRPC + rpc->getBatchRPC(splits, + [=] (double /*unused*/) { + json payload = { + {"jsonrpc", "1.0"}, + {"id", "someid"}, + {"method", "getnewaddress"}, + }; + return payload; + }, + [=] (QMap* newAddrs) { + // Get block numbers + auto curBlock = Settings::getInstance()->getBlockNumber(); + auto blockNumbers = getBlockNumbers(curBlock, curBlock + 10, splits.size()); + + // Assign the amounts to the addresses. + QList migItems; + + for (int i=0; i < splits.size(); i++) { + auto tAddr = newAddrs->values()[i].get(); + auto item = TurnstileMigrationItem { zaddr, QString::fromStdString(tAddr), destAddr, + blockNumbers[i], splits[i], i == splits.size() -1 }; + migItems.push_back(item); + } + + std::sort(migItems.begin(), migItems.end(), [&] (auto a, auto b) { + return a.blockNumber < b.blockNumber; + }); + + // The first migration is shifted to the current block, so the user sees something + // happening immediately + migItems[0].blockNumber = curBlock; + + writeMigrationPlan(migItems); + auto readPlan = readMigrationPlan(); + + for (auto item : readPlan) { + qDebug() << item.fromAddr << item.intTAddr + << item.destAddr << item.amount << item.blockNumber << item.chaff; + } + } + ); +} + +QList Turnstile::getBlockNumbers(int start, int end, int count) { + QList blocks; + // Generate 'count' numbers between [start, end] + for (int i=0; i < count; i++) { + auto blk = (std::rand() % (end - start)) + start; + blocks.push_back(blk); + } + + return blocks; +} + QList Turnstile::splitAmount(double amount, int parts) { QList amounts; // Need at least 0.0004 ZEC for this diff --git a/src/turnstile.h b/src/turnstile.h index 7a4bac7..427634b 100644 --- a/src/turnstile.h +++ b/src/turnstile.h @@ -1,16 +1,37 @@ #ifndef TURNSTILE_H #define TURNSTILE_H + #include "precompiled.h" +class RPC; + +struct TurnstileMigrationItem { + QString fromAddr; + QString intTAddr; + QString destAddr; + int blockNumber; + double amount; + bool chaff; +}; + class Turnstile { public: - Turnstile(); + Turnstile(RPC* _rpc); ~Turnstile(); + void planMigration(QString zaddr, QString destAddr); QList splitAmount(double amount, int parts); void fillAmounts(QList& amounts, double amount, int count); + + void writeMigrationPlan(QList plan); + QList readMigrationPlan(); + +private: + QList getBlockNumbers(int start, int end, int count); + QString writeableFile(); + RPC* rpc; }; #endif \ No newline at end of file diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index 7ae1f78..1b40335 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -13,7 +13,7 @@ PRECOMPILED_HEADER = src/precompiled.h greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = zec-qt-wallet -APP_VERSION=\\\"0.2.2\\\" +APP_VERSION=\\\"0.2.3\\\" TEMPLATE = app