diff --git a/silentdragon.pro b/silentdragon.pro index 9832e5d..7427afe 100644 --- a/silentdragon.pro +++ b/silentdragon.pro @@ -96,6 +96,7 @@ FORMS += \ src/about.ui \ src/confirm.ui \ src/privkey.ui \ + src/importviewkey.ui \ src/viewkey.ui \ src/memodialog.ui \ src/viewalladdresses.ui \ diff --git a/src/importviewkey.ui b/src/importviewkey.ui new file mode 100644 index 0000000..f4d451d --- /dev/null +++ b/src/importviewkey.ui @@ -0,0 +1,85 @@ + + + ImportViewKey + + + + 0 + 0 + 400 + 300 + + + + Import Viewing Key + + + + + + Import a viewing key to see transactions to a zaddr + + + + + + + Viewing Key: + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + ImportViewKey + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ImportViewKey + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f2010d7..ff9a3c5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -9,6 +9,7 @@ #include "ui_addressbook.h" #include "ui_privkey.h" #include "ui_viewkey.h" +#include "ui_importviewkey.h" #include "ui_about.h" #include "ui_settings.h" #include "ui_viewalladdresses.h" @@ -92,6 +93,9 @@ MainWindow::MainWindow(QWidget *parent) : // Validate Address QObject::connect(ui->actionValidate_Address, &QAction::triggered, this, &MainWindow::validateAddress); + // Import viewkey + QObject::connect(ui->actionImport_Viewkey, &QAction::triggered, this, &MainWindow::importViewKey); + // Connect mobile app QObject::connect(ui->actionConnect_Mobile_App, &QAction::triggered, this, [=] () { if (rpc->getConnection() == nullptr) @@ -518,9 +522,50 @@ void MainWindow::donate() { ui->tabWidget->setCurrentIndex(1); } -/** - * Validate an address - */ +// Import a zaddr viewkey +void MainWindow::importViewKey() { + qDebug() << "Import viewing key"; + if (!getRPC() || !getRPC()->getConnection()) + return; + + bool ok; + qDebug() << "Import viewing key dialog"; + auto viewkey = QInputDialog::getText(this, tr("Enter Sapling viewing key (from z_exportviewingkey)"), + tr("Viewing Key (starts with zivk...) :") + QString(" ").repeated(140), // Pad the label so the dialog box is wide enough + QLineEdit::Normal, "", &ok); + if (!ok) + return; + qDebug() << "Importing " << viewkey; + +/* + getRPC()->importViewKey(viewkey, [=] (json props) { + QDialog d(this); + Ui_ValidateAddress va; + va.setupUi(&d); + Settings::saveRestore(&d); + Settings::saveRestoreTableHeader(va.tblProps, &d, "validateaddressprops"); + va.tblProps->horizontalHeader()->setStretchLastSection(true); + + va.lblAddress->setText(address); + + QList> propsList; + for (auto it = props.begin(); it != props.end(); it++) { + + propsList.append( + QPair( + QString::fromStdString(it.key()), QString::fromStdString(it.value().dump())) + ); + } + + ValidateAddressesModel model(va.tblProps, propsList); + va.tblProps->setModel(&model); + + d.exec(); + }); +*/ +} + +// Validate a taddr or zaddr address void MainWindow::validateAddress() { // Make sure everything is up and running if (!getRPC() || !getRPC()->getConnection()) diff --git a/src/mainwindow.h b/src/mainwindow.h index 9a2f5be..ae59f6e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -122,6 +122,7 @@ private: void addressBook(); void postToZBoard(); void importPrivKey(); + void importViewKey(); void exportAllKeys(); void exportKeys(QString addr = ""); void getViewKey(QString addr = ""); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 54459ab..7b9f499 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1520,6 +1520,7 @@ + @@ -1645,6 +1646,11 @@ Validate Address + + + Import Viewing Key + +