Browse Source

Work in progress importing of view keys. Needs a more complex UI to input viewkey, address, rescan and height

importviewkey
Duke Leto 4 years ago
parent
commit
6a904cadf2
  1. 1
      silentdragon.pro
  2. 85
      src/importviewkey.ui
  3. 51
      src/mainwindow.cpp
  4. 1
      src/mainwindow.h
  5. 6
      src/mainwindow.ui

1
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 \

85
src/importviewkey.ui

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImportViewKey</class>
<widget class="QDialog" name="ImportViewKey">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Import Viewing Key</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="lblAddress">
<property name="text">
<string>Import a viewing key to see transactions to a zaddr</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Viewing Key:</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QTableView" name="tblProps">
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ImportViewKey</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ImportViewKey</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

51
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<QPair<QString, QString>> propsList;
for (auto it = props.begin(); it != props.end(); it++) {
propsList.append(
QPair<QString, QString>(
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())

1
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 = "");

6
src/mainwindow.ui

@ -1520,6 +1520,7 @@
</property>
<addaction name="actionConnect_Mobile_App"/>
<addaction name="actionValidate_Address"/>
<addaction name="actionImport_Viewkey"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu_Edit">
@ -1645,6 +1646,11 @@
<string>Validate Address</string>
</property>
</action>
<action name="actionImport_Viewkey">
<property name="text">
<string>Import Viewing Key</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

Loading…
Cancel
Save