diff --git a/src/controller.h b/src/controller.h index 5b31e39..fba66a1 100644 --- a/src/controller.h +++ b/src/controller.h @@ -64,14 +64,12 @@ public: void createNewZaddr(bool sapling, const std::function& cb) { zrpc->createNewZaddr(sapling, cb); } void createNewTaddr(const std::function& cb) { zrpc->createNewTaddr(cb); } - void validateAddress(QString address, const std::function& cb) { zrpc->validateAddress(address, cb); } - void fetchZPrivKey(QString addr, const std::function& cb) { zrpc->fetchZPrivKey(addr, cb); } void fetchTPrivKey(QString addr, const std::function& cb) { zrpc->fetchTPrivKey(addr, cb); } void fetchAllPrivKeys(const std::function>)> cb) { zrpc->fetchAllPrivKeys(cb); } - void importZPrivKey(QString addr, bool rescan, const std::function& cb) { zrpc->importZPrivKey(addr, rescan, cb); } - void importTPrivKey(QString addr, bool rescan, const std::function& cb) { zrpc->importTPrivKey(addr, rescan, cb); } + // void importZPrivKey(QString addr, bool rescan, const std::function& cb) { zrpc->importZPrivKey(addr, rescan, cb); } + // void importTPrivKey(QString addr, bool rescan, const std::function& cb) { zrpc->importTPrivKey(addr, rescan, cb); } QString getDefaultSaplingAddress(); QString getDefaultTAddress(); diff --git a/src/liteinterface.cpp b/src/liteinterface.cpp index b709d67..261ee65 100644 --- a/src/liteinterface.cpp +++ b/src/liteinterface.cpp @@ -44,31 +44,18 @@ void LiteInterface::fetchUnspent(const std::function& cb) { // conn->doRPCWithDefaultErrorHandling(payload, cb); } -void LiteInterface::createNewZaddr(bool sapling, const std::function& cb) { +void LiteInterface::createNewZaddr(bool, const std::function& cb) { if (conn == nullptr) return; - // json payload = { - // {"jsonrpc", "1.0"}, - // {"id", "someid"}, - // {"method", "z_getnewaddress"}, - // {"params", { sapling ? "sapling" : "sprout" }}, - // }; - - // conn->doRPCWithDefaultErrorHandling(payload, cb); + conn->doRPCWithDefaultErrorHandling("new", "z", cb); } void LiteInterface::createNewTaddr(const std::function& cb) { if (conn == nullptr) return; - // json payload = { - // {"jsonrpc", "1.0"}, - // {"id", "someid"}, - // {"method", "getnewaddress"}, - // }; - - // conn->doRPCWithDefaultErrorHandling(payload, cb); + conn->doRPCWithDefaultErrorHandling("new", "t", cb); } void LiteInterface::fetchZPrivKey(QString addr, const std::function& cb) { @@ -99,50 +86,34 @@ void LiteInterface::fetchTPrivKey(QString addr, const std::function& // conn->doRPCWithDefaultErrorHandling(payload, cb); } -void LiteInterface::importZPrivKey(QString addr, bool rescan, const std::function& cb) { - if (conn == nullptr) - return; - - // json payload = { - // {"jsonrpc", "1.0"}, - // {"id", "someid"}, - // {"method", "z_importkey"}, - // {"params", { addr.toStdString(), (rescan? "yes" : "no") }}, - // }; - - // conn->doRPCWithDefaultErrorHandling(payload, cb); -} - - -void LiteInterface::importTPrivKey(QString addr, bool rescan, const std::function& cb) { - if (conn == nullptr) - return; +// void LiteInterface::importZPrivKey(QString addr, bool rescan, const std::function& cb) { +// if (conn == nullptr) +// return; - // json payload = { - // {"jsonrpc", "1.0"}, - // {"id", "someid"}, - // {"method", "importprivkey"}, - // {"params", { addr.toStdString(), (rescan? "yes" : "no") }}, - // }; +// // json payload = { +// // {"jsonrpc", "1.0"}, +// // {"id", "someid"}, +// // {"method", "z_importkey"}, +// // {"params", { addr.toStdString(), (rescan? "yes" : "no") }}, +// // }; - // conn->doRPCWithDefaultErrorHandling(payload, cb); -} +// // conn->doRPCWithDefaultErrorHandling(payload, cb); +// } -void LiteInterface::validateAddress(QString address, const std::function& cb) { - if (conn == nullptr) - return; - // QString method = Settings::isZAddress(address) ? "z_validateaddress" : "validateaddress"; +// void LiteInterface::importTPrivKey(QString addr, bool rescan, const std::function& cb) { +// if (conn == nullptr) +// return; - // json payload = { - // {"jsonrpc", "1.0"}, - // {"id", "someid"}, - // {"method", method.toStdString() }, - // {"params", { address.toStdString() } }, - // }; +// // json payload = { +// // {"jsonrpc", "1.0"}, +// // {"id", "someid"}, +// // {"method", "importprivkey"}, +// // {"params", { addr.toStdString(), (rescan? "yes" : "no") }}, +// // }; - // conn->doRPCWithDefaultErrorHandling(payload, cb); -} +// // conn->doRPCWithDefaultErrorHandling(payload, cb); +// } void LiteInterface::fetchBalance(const std::function& cb) { if (conn == nullptr) diff --git a/src/liteinterface.h b/src/liteinterface.h index e4d2469..29218cd 100644 --- a/src/liteinterface.h +++ b/src/liteinterface.h @@ -62,10 +62,9 @@ public: void fetchZPrivKey(QString addr, const std::function& cb); void fetchTPrivKey(QString addr, const std::function& cb); - void importZPrivKey(QString addr, bool rescan, const std::function& cb); - void importTPrivKey(QString addr, bool rescan, const std::function& cb); - void validateAddress(QString address, const std::function& cb); - + //void importZPrivKey(QString addr, bool rescan, const std::function& cb); + //void importTPrivKey(QString addr, bool rescan, const std::function& cb); + void fetchAllPrivKeys(const std::function>)>); void sendTransaction(QString params, const std::function& cb, const std::function& err); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4ca4458..ccd9177 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,7 +1,6 @@ #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,7 +10,6 @@ #include "ui_settings.h" #include "ui_turnstileprogress.h" #include "ui_viewalladdresses.h" -#include "ui_validateaddress.h" #include "controller.h" #include "balancestablemodel.h" #include "settings.h" @@ -83,9 +81,6 @@ MainWindow::MainWindow(QWidget *parent) : payZcashURI(); }); - // Import Private Key - QObject::connect(ui->actionImport_Private_Key, &QAction::triggered, this, &MainWindow::importPrivKey); - // Export All Private Keys QObject::connect(ui->actionExport_All_Private_Keys, &QAction::triggered, this, &MainWindow::exportAllKeys); @@ -95,13 +90,6 @@ MainWindow::MainWindow(QWidget *parent) : // Export transactions QObject::connect(ui->actionExport_transactions, &QAction::triggered, this, &MainWindow::exportTransactions); - // Z-board seems to have been abandoned - // 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) @@ -447,73 +435,30 @@ 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> 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(); - }); - -} - -void MainWindow::doImport(QList* keys) { - if (rpc->getConnection() == nullptr) { - // No connection, just return - return; - } +// void MainWindow::doImport(QList* keys) { +// if (rpc->getConnection() == nullptr) { +// // No connection, just return +// return; +// } - if (keys->isEmpty()) { - delete keys; - ui->statusBar->showMessage(tr("Private key import rescan finished")); - return; - } +// if (keys->isEmpty()) { +// delete keys; +// ui->statusBar->showMessage(tr("Private key import rescan finished")); +// return; +// } - // Pop the first key - QString key = keys->first(); - keys->pop_front(); - bool rescan = keys->isEmpty(); +// // Pop the first key +// QString key = keys->first(); +// keys->pop_front(); +// bool rescan = keys->isEmpty(); - if (key.startsWith("SK") || - key.startsWith("secret")) { // Z key - rpc->importZPrivKey(key, rescan, [=] (auto) { this->doImport(keys); }); - } else { - rpc->importTPrivKey(key, rescan, [=] (auto) { this->doImport(keys); }); - } -} +// if (key.startsWith("SK") || +// key.startsWith("secret")) { // Z key +// rpc->importZPrivKey(key, rescan, [=] (auto) { this->doImport(keys); }); +// } else { +// rpc->importTPrivKey(key, rescan, [=] (auto) { this->doImport(keys); }); +// } +// } // Callback invoked when the RPC has finished loading all the balances, and the UI @@ -606,50 +551,50 @@ void MainWindow::payZcashURI(QString uri, QString myAddr) { } -void MainWindow::importPrivKey() { - QDialog d(this); - Ui_PrivKey pui; - pui.setupUi(&d); - Settings::saveRestore(&d); - - pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(false); - pui.helpLbl->setText(QString() % - tr("Please paste your private keys (z-Addr or t-Addr) here, one per line") % ".\n" % - tr("The keys will be imported into your connected zcashd node")); - - if (d.exec() == QDialog::Accepted && !pui.privKeyTxt->toPlainText().trimmed().isEmpty()) { - auto rawkeys = pui.privKeyTxt->toPlainText().trimmed().split("\n"); - - QList keysTmp; - // Filter out all the empty keys. - std::copy_if(rawkeys.begin(), rawkeys.end(), std::back_inserter(keysTmp), [=] (auto key) { - return !key.startsWith("#") && !key.trimmed().isEmpty(); - }); - - auto keys = new QList(); - std::transform(keysTmp.begin(), keysTmp.end(), std::back_inserter(*keys), [=](auto key) { - return key.trimmed().split(" ")[0]; - }); - - // Special case. - // Sometimes, when importing from a paperwallet or such, the key is split by newlines, and might have - // been pasted like that. So check to see if the whole thing is one big private key - if (Settings::getInstance()->isValidSaplingPrivateKey(keys->join(""))) { - auto multiline = keys; - keys = new QList(); - keys->append(multiline->join("")); - delete multiline; - } - - // Start the import. The function takes ownership of keys - QTimer::singleShot(1, [=]() {doImport(keys);}); - - // Show the dialog that keys will be imported. - QMessageBox::information(this, - "Imported", tr("The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited"), - QMessageBox::Ok); - } -} +// void MainWindow::importPrivKey() { +// QDialog d(this); +// Ui_PrivKey pui; +// pui.setupUi(&d); +// Settings::saveRestore(&d); + +// pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(false); +// pui.helpLbl->setText(QString() % +// tr("Please paste your private keys (z-Addr or t-Addr) here, one per line") % ".\n" % +// tr("The keys will be imported into your connected zcashd node")); + +// if (d.exec() == QDialog::Accepted && !pui.privKeyTxt->toPlainText().trimmed().isEmpty()) { +// auto rawkeys = pui.privKeyTxt->toPlainText().trimmed().split("\n"); + +// QList keysTmp; +// // Filter out all the empty keys. +// std::copy_if(rawkeys.begin(), rawkeys.end(), std::back_inserter(keysTmp), [=] (auto key) { +// return !key.startsWith("#") && !key.trimmed().isEmpty(); +// }); + +// auto keys = new QList(); +// std::transform(keysTmp.begin(), keysTmp.end(), std::back_inserter(*keys), [=](auto key) { +// return key.trimmed().split(" ")[0]; +// }); + +// // Special case. +// // Sometimes, when importing from a paperwallet or such, the key is split by newlines, and might have +// // been pasted like that. So check to see if the whole thing is one big private key +// if (Settings::getInstance()->isValidSaplingPrivateKey(keys->join(""))) { +// auto multiline = keys; +// keys = new QList(); +// keys->append(multiline->join("")); +// delete multiline; +// } + +// // Start the import. The function takes ownership of keys +// QTimer::singleShot(1, [=]() {doImport(keys);}); + +// // Show the dialog that keys will be imported. +// QMessageBox::information(this, +// "Imported", tr("The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited"), +// QMessageBox::Ok); +// } +// } /** * Export transaction history into a CSV file @@ -967,7 +912,7 @@ void MainWindow::setupTransactionsTab() { void MainWindow::addNewZaddr(bool sapling) { rpc->createNewZaddr(sapling, [=] (json reply) { - QString addr = QString::fromStdString(reply.get()); + QString addr = QString::fromStdString(reply.get()[0]); // Make sure the RPC class reloads the z-addrs for future use rpc->refreshAddresses(); @@ -1018,7 +963,7 @@ std::function MainWindow::addZAddrsToComboList(bool sapling) { void MainWindow::setupReceiveTab() { auto addNewTAddr = [=] () { rpc->createNewTaddr([=] (json reply) { - QString addr = QString::fromStdString(reply.get()); + QString addr = QString::fromStdString(reply.get()[0]); // Make sure the RPC class reloads the t-addrs for future use rpc->refreshAddresses(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 553b18e..ca6432d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -57,8 +57,6 @@ public: void balancesReady(); void payZcashURI(QString uri = "", QString myAddr = ""); - void validateAddress(); - void updateLabels(); void updateTAddrCombo(bool checked); void updateFromCombo(); @@ -119,7 +117,6 @@ private: void donate(); void addressBook(); - //void postToZBoard(); void importPrivKey(); void exportAllKeys(); void exportKeys(QString addr = ""); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 44287c1..b578c02 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1062,7 +1062,6 @@ - @@ -1084,10 +1083,6 @@ &Apps - - - - @@ -1131,19 +1126,6 @@ Check github.com for &updates - - - Sapling &turnstile - - - Ctrl+A, Ctrl+T - - - - - &Import private key - - &Export all private keys @@ -1195,11 +1177,6 @@ File a bug... - - - Validate Address - - diff --git a/src/turnstileprogress.ui b/src/turnstileprogress.ui deleted file mode 100644 index d52b72e..0000000 --- a/src/turnstileprogress.ui +++ /dev/null @@ -1,192 +0,0 @@ - - - TurnstileProgress - - - - 0 - 0 - 400 - 300 - - - - Turnstile Migration Progress - - - - - - From - - - - - - - To - - - - - - - From Address - - - - - - - 4 / 12 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Please ensure you have your wallet.dat backed up! - - - true - - - - - - - Next Transaction in 4 hours - - - - - - - 33 - - - - - - - Qt::Horizontal - - - - - - - Migration Progress - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close|QDialogButtonBox::Discard - - - false - - - - - - - - 0 - 0 - - - - TextLabel - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - - - - - To Address - - - - - - - Qt::Horizontal - - - - - - - - - buttonBox - accepted() - TurnstileProgress - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - TurnstileProgress - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/validateaddress.cpp b/src/validateaddress.cpp deleted file mode 100644 index d82e82e..0000000 --- a/src/validateaddress.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "validateaddress.h" - - -ValidateAddressesModel::ValidateAddressesModel(QTableView *parent, QList> props) - : QAbstractTableModel(parent) { - headers << tr("Property") << tr("Value"); - this->props = props; -} - - -int ValidateAddressesModel::rowCount(const QModelIndex&) const { - return props.size(); -} - -int ValidateAddressesModel::columnCount(const QModelIndex&) const { - return headers.size(); -} - -QVariant ValidateAddressesModel::data(const QModelIndex &index, int role) const { - QPair p = props.at(index.row()); - if (role == Qt::DisplayRole) { - switch(index.column()) { - case 0: return p.first; - case 1: return p.second; - } - } - return QVariant(); -} - - -QVariant ValidateAddressesModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { - return headers.at(section); - } - - return QVariant(); -} diff --git a/src/validateaddress.h b/src/validateaddress.h deleted file mode 100644 index 19db4cb..0000000 --- a/src/validateaddress.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef VALIDATEADDRESS_H -#define VALIDATEADDRESS_H - -#include "precompiled.h" - -class ValidateAddressesModel : public QAbstractTableModel { - -public: - ValidateAddressesModel(QTableView* parent, QList> props); - ~ValidateAddressesModel() = default; - - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - -private: - QList> props; - QStringList headers; -}; - - -#endif // VALIDATEADDRESS_H diff --git a/src/validateaddress.ui b/src/validateaddress.ui deleted file mode 100644 index 20caebb..0000000 --- a/src/validateaddress.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - ValidateAddress - - - - 0 - 0 - 400 - 300 - - - - Validate Address - - - - - - TextLabel - - - - - - - Address: - - - - - - - true - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - - buttonBox - accepted() - ValidateAddress - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - ValidateAddress - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/zboard.ui b/src/zboard.ui deleted file mode 100644 index b21db5e..0000000 --- a/src/zboard.ui +++ /dev/null @@ -1,170 +0,0 @@ - - - zboard - - - - 0 - 0 - 588 - 431 - - - - Post to z-board.net - - - - - - Total Fee - - - - - - - feeamount - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 / 512 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Memo - - - - - - - (optional) - - - - - - - Send From - - - - - - - Post As: - - - - - - - <html><head/><body><p>ZBoard: Fully anonymous and untraceable chat messages based on the ZCash blockchain. <a href="http://www.z-board.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.z-board.net/</span></a></p></body></html> - - - true - - - true - - - - - - - - - - - - - color:red; - - - Warning - - - - - - - Qt::Horizontal - - - - - - - - - - Posting to Board - - - - - - - fromAddr - postAs - memoTxt - - - - - buttonBox - accepted() - zboard - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - zboard - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/zecwallet-lite.pro b/zecwallet-lite.pro index 1a54595..85c1c0a 100644 --- a/zecwallet-lite.pro +++ b/zecwallet-lite.pro @@ -51,7 +51,6 @@ SOURCES += \ src/addressbook.cpp \ src/logger.cpp \ src/addresscombo.cpp \ - src/validateaddress.cpp \ src/websockets.cpp \ src/mobileappconnector.cpp \ src/recurring.cpp \ @@ -78,7 +77,6 @@ HEADERS += \ src/addressbook.h \ src/logger.h \ src/addresscombo.h \ - src/validateaddress.h \ src/websockets.h \ src/mobileappconnector.h \ src/recurring.h \ @@ -97,13 +95,10 @@ FORMS += \ src/settings.ui \ src/about.ui \ src/confirm.ui \ - src/turnstileprogress.ui \ src/privkey.ui \ src/memodialog.ui \ - src/validateaddress.ui \ src/viewalladdresses.ui \ src/connection.ui \ - src/zboard.ui \ src/addressbook.ui \ src/mobileappconnector.ui \ src/createzcashconfdialog.ui \