171 - Validate address

This commit is contained in:
Aditya Kulkarni
2019-07-24 10:23:59 -07:00
committed by Aditya Kulkarni
parent df1cbe6570
commit 1219651f76
9 changed files with 219 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
#include "mainwindow.h"
#include "addressbook.h"
#include "viewalladdresses.h"
#include "validateaddress.h"
#include "ui_mainwindow.h"
#include "ui_mobileappconnector.h"
#include "ui_addressbook.h"
@@ -11,6 +12,7 @@
#include "ui_turnstile.h"
#include "ui_turnstileprogress.h"
#include "ui_viewalladdresses.h"
#include "ui_validateaddress.h"
#include "rpc.h"
#include "balancestablemodel.h"
#include "settings.h"
@@ -83,6 +85,9 @@ MainWindow::MainWindow(QWidget *parent) :
// z-Board.net
QObject::connect(ui->actionz_board_net, &QAction::triggered, this, &MainWindow::postToZBoard);
// Validate Address
QObject::connect(ui->actionValidate_Address, &QAction::triggered, this, &MainWindow::validateAddress);
// Connect mobile app
QObject::connect(ui->actionConnect_Mobile_App, &QAction::triggered, this, [=] () {
if (rpc->getConnection() == nullptr)
@@ -644,6 +649,48 @@ void MainWindow::donate() {
ui->tabWidget->setCurrentIndex(1);
}
/**
* Validate an address
*/
void MainWindow::validateAddress() {
// Make sure everything is up and running
if (!getRPC() || !getRPC()->getConnection())
return;
// First thing is ask the user for an address
bool ok;
auto address = QInputDialog::getText(this, tr("Enter Address to validate"),
tr("Transparent or Shielded Address:") + QString(" ").repeated(140), // Pad the label so the dialog box is wide enough
QLineEdit::Normal, "", &ok);
if (!ok)
return;
getRPC()->validateAddress(address, [=] (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();
});
}
void MainWindow::postToZBoard() {
QDialog d(this);
@@ -1233,7 +1280,6 @@ void MainWindow::setupTransactionsTab() {
}
void MainWindow::addNewZaddr(bool sapling) {
rpc->newZaddr(sapling, [=] (json reply) {
QString addr = QString::fromStdString(reply.get<json::string_t>());
// Make sure the RPC class reloads the z-addrs for future use
@@ -1325,6 +1371,7 @@ void MainWindow::setupReceiveTab() {
viewaddrs.setupUi(&d);
Settings::saveRestore(&d);
Settings::saveRestoreTableHeader(viewaddrs.tblAddresses, &d, "viewalladdressestable");
viewaddrs.tblAddresses->horizontalHeader()->setStretchLastSection(true);
ViewAllAddressesModel model(viewaddrs.tblAddresses, *getRPC()->getAllTAddresses(), getRPC());
viewaddrs.tblAddresses->setModel(&model);