From 94bfcd50fce62eb0b6df126b97abb37661f8cae2 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Fri, 9 Nov 2018 15:24:32 -0800 Subject: [PATCH] cleanup --- src/addressbook.cpp | 6 +-- src/balancestablemodel.cpp | 2 +- src/balancestablemodel.h | 10 ++++- src/connection.cpp | 15 ++++---- src/mainwindow.cpp | 20 +++++----- src/rpc.cpp | 16 ++++---- src/rpc.h | 1 - src/sendtab.cpp | 28 +++++++------- src/settings.cpp | 77 +++++++++++++++++++++++++++++++++++++- src/settings.h | 23 ++++++++++++ src/turnstile.cpp | 16 ++++---- src/txtablemodel.cpp | 2 +- src/unspentoutput.cpp | 1 - src/unspentoutput.h | 15 -------- src/utils.cpp | 72 ----------------------------------- src/utils.h | 34 ----------------- zec-qt-wallet.pro | 4 -- 17 files changed, 158 insertions(+), 184 deletions(-) delete mode 100644 src/unspentoutput.cpp delete mode 100644 src/unspentoutput.h delete mode 100644 src/utils.cpp delete mode 100644 src/utils.h diff --git a/src/addressbook.cpp b/src/addressbook.cpp index 873eac2..245fa6a 100644 --- a/src/addressbook.cpp +++ b/src/addressbook.cpp @@ -3,7 +3,7 @@ #include "ui_mainwindow.h" #include "settings.h" #include "mainwindow.h" -#include "utils.h" + AddressBookModel::AddressBookModel(QTableView *parent) : QAbstractTableModel(parent) { @@ -104,7 +104,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabelsAutoComplete(); }); // If there is a target then make it the addr for the "Add to" button - if (target != nullptr && Utils::isValidAddress(target->text())) { + if (target != nullptr && Settings::isValidAddress(target->text())) { ab.addr->setText(target->text()); ab.label->setFocus(); } @@ -114,7 +114,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { auto addr = ab.addr->text().trimmed(); if (!addr.isEmpty() && !ab.label->text().isEmpty()) { // Test if address is valid. - if (!Utils::isValidAddress(addr)) { + if (!Settings::isValidAddress(addr)) { QMessageBox::critical(parent, "Address Format Error", addr + " doesn't seem to be a valid Zcash address.", QMessageBox::Ok); } else { model.addNewLabel(ab.label->text(), ab.addr->text()); diff --git a/src/balancestablemodel.cpp b/src/balancestablemodel.cpp index a7ea26e..9d45aa9 100644 --- a/src/balancestablemodel.cpp +++ b/src/balancestablemodel.cpp @@ -1,6 +1,6 @@ #include "balancestablemodel.h" #include "settings.h" -#include "utils.h" + BalancesTableModel::BalancesTableModel(QObject *parent) : QAbstractTableModel(parent) { diff --git a/src/balancestablemodel.h b/src/balancestablemodel.h index 26937eb..bcaa5d7 100644 --- a/src/balancestablemodel.h +++ b/src/balancestablemodel.h @@ -1,10 +1,16 @@ #ifndef BALANCESTABLEMODEL_H #define BALANCESTABLEMODEL_H -#include "unspentoutput.h" - #include "precompiled.h" +struct UnspentOutput { + QString address; + QString txid; + QString amount; + int confirmations; + bool spendable; +}; + class BalancesTableModel : public QAbstractTableModel { public: diff --git a/src/connection.cpp b/src/connection.cpp index f1f1f26..1c9c07c 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -228,7 +228,6 @@ bool ConnectionLoader::startEmbeddedZcashd() { } // Finally, start zcashd - qDebug() << "Starting zcashd"; QFileInfo fi(Settings::getInstance()->getExecName()); #ifdef Q_OS_LINUX auto zcashdProgram = fi.dir().absoluteFilePath("zcashd"); @@ -245,16 +244,16 @@ bool ConnectionLoader::startEmbeddedZcashd() { ezcashd = new QProcess(main); QObject::connect(ezcashd, &QProcess::started, [=] () { - qDebug() << "zcashd started"; + //qDebug() << "zcashd started"; }); QObject::connect(ezcashd, QOverload::of(&QProcess::finished), - [=](int exitCode, QProcess::ExitStatus exitStatus) { - qDebug() << "zcashd finished with code " << exitCode << "," << exitStatus; + [=](int, QProcess::ExitStatus) { + //qDebug() << "zcashd finished with code " << exitCode << "," << exitStatus; }); - QObject::connect(ezcashd, &QProcess::errorOccurred, [&] (auto error) mutable { - qDebug() << "Couldn't start zcashd: " << error; + QObject::connect(ezcashd, &QProcess::errorOccurred, [&] (auto) { + //qDebug() << "Couldn't start zcashd: " << error; }); ezcashd->start(zcashdProgram); @@ -510,7 +509,7 @@ Connection::~Connection() { void Connection::doRPC(const json& payload, const std::function& cb, const std::function& ne) { if (shutdownInProgress) { - qDebug() << "Ignoring RPC because shutdown in progress"; + // Ignoring RPC because shutdown in progress return; } @@ -519,7 +518,7 @@ void Connection::doRPC(const json& payload, const std::function& cb, QObject::connect(reply, &QNetworkReply::finished, [=] { reply->deleteLater(); if (shutdownInProgress) { - qDebug() << "Ignoring callback because shutdown in progress"; + // Ignoring callback because shutdown in progress return; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cd97d07..a4c624e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -11,7 +11,7 @@ #include "rpc.h" #include "balancestablemodel.h" #include "settings.h" -#include "utils.h" + #include "turnstile.h" #include "senttxstore.h" #include "connection.h" @@ -151,7 +151,7 @@ void MainWindow::turnstileProgress() { QTimer progressTimer(this); QObject::connect(&progressTimer, &QTimer::timeout, fnUpdateProgressUI); - progressTimer.start(Utils::updateSpeed); + progressTimer.start(Settings::updateSpeed); fnUpdateProgressUI(); auto curProgress = rpc->getTurnstile()->getPlanProgress(); @@ -257,7 +257,7 @@ void MainWindow::turnstileDoMigration(QString fromAddr) { QObject::connect(turnstile.privLevel, QOverload::of(&QComboBox::currentIndexChanged), [=] (auto idx) { // Update the fees turnstile.minerFee->setText( - Settings::getInstance()->getZECUSDDisplayFormat(std::get<0>(privOptions[idx]) * Utils::getMinerFee())); + Settings::getInstance()->getZECUSDDisplayFormat(std::get<0>(privOptions[idx]) * Settings::getMinerFee())); }); for (auto i : privOptions) { @@ -312,7 +312,7 @@ void MainWindow::setupStatusBar() { auto msg = ui->statusBar->currentMessage(); QMenu menu(this); - if (!msg.isEmpty() && msg.startsWith(Utils::txidStatusMessage)) { + if (!msg.isEmpty() && msg.startsWith(Settings::txidStatusMessage)) { auto txid = msg.split(":")[1].trimmed(); menu.addAction("Copy txid", [=]() { QGuiApplication::clipboard()->setText(txid); @@ -434,13 +434,13 @@ void MainWindow::addressBook() { void MainWindow::donate() { // Set up a donation to me :) - ui->Address1->setText(Utils::getDonationAddr( + ui->Address1->setText(Settings::getDonationAddr( Settings::getInstance()->isSaplingAddress(ui->inputsCombo->currentText()))); ui->Address1->setCursorPosition(0); ui->Amount1->setText("0.01"); ui->MemoTxt1->setText("Thanks for supporting zec-qt-wallet!"); - ui->statusBar->showMessage("Donate 0.01 " % Utils::getTokenName() % " to support zec-qt-wallet"); + ui->statusBar->showMessage("Donate 0.01 " % Settings::getTokenName() % " to support zec-qt-wallet"); // And switch to the send tab. ui->tabWidget->setCurrentIndex(1); @@ -464,7 +464,7 @@ void MainWindow::postToZBoard() { QMap topics; // Insert the main topic automatically - topics.insert("#Main_Area", Utils::getZboardAddr()); + topics.insert("#Main_Area", Settings::getZboardAddr()); zb.topicsList->addItem(topics.firstKey()); // Then call the API to get topics, and if it returns successfully, then add the rest of the topics rpc->getZboardTopics([&](QMap topicsMap) { @@ -485,7 +485,7 @@ void MainWindow::postToZBoard() { QRegExpValidator v(QRegExp("^[a-zA-Z0-9_]{3,20}$"), zb.postAs); zb.postAs->setValidator(&v); - zb.feeAmount->setText(Settings::getInstance()->getZECUSDDisplayFormat(Utils::getZboardAmount() + Utils::getMinerFee())); + zb.feeAmount->setText(Settings::getInstance()->getZECUSDDisplayFormat(Settings::getZboardAmount() + Settings::getMinerFee())); auto fnBuildNameMemo = [=]() -> QString { auto memo = zb.memoTxt->toPlainText().trimmed(); @@ -541,8 +541,8 @@ void MainWindow::postToZBoard() { memo = zb.postAs->text().trimmed() + ":: " + memo; auto toAddr = topics[zb.topicsList->currentText()]; - tx.toAddrs.push_back(ToFields{ toAddr, Utils::getZboardAmount(), memo, memo.toUtf8().toHex() }); - tx.fee = Utils::getMinerFee(); + tx.toAddrs.push_back(ToFields{ toAddr, Settings::getZboardAmount(), memo, memo.toUtf8().toHex() }); + tx.fee = Settings::getMinerFee(); json params = json::array(); rpc->fillTxJsonParams(params, tx); diff --git a/src/rpc.cpp b/src/rpc.cpp index a0aa2c5..285c672 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1,5 +1,5 @@ #include "rpc.h" -#include "utils.h" + #include "settings.h" #include "senttxstore.h" #include "turnstile.h" @@ -31,14 +31,14 @@ RPC::RPC(MainWindow* main) { QObject::connect(priceTimer, &QTimer::timeout, [=]() { refreshZECPrice(); }); - priceTimer->start(Utils::priceRefreshSpeed); // Every hour + priceTimer->start(Settings::priceRefreshSpeed); // Every hour // Set up a timer to refresh the UI every few seconds timer = new QTimer(main); QObject::connect(timer, &QTimer::timeout, [=]() { refresh(); }); - timer->start(Utils::updateSpeed); + timer->start(Settings::updateSpeed); // Set up the timer to watch for tx status txTimer = new QTimer(main); @@ -46,7 +46,7 @@ RPC::RPC(MainWindow* main) { watchTxStatus(); }); // Start at every 10s. When an operation is pending, this will change to every second - txTimer->start(Utils::updateSpeed); + txTimer->start(Settings::updateSpeed); } RPC::~RPC() { @@ -584,7 +584,7 @@ void RPC::updateUI(bool anyUnconfirmed) { ui->inputsCombo->clear(); auto i = allBalances->constBegin(); while (i != allBalances->constEnd()) { - QString item = i.key() % "(" % QString::number(i.value(), 'g', 8) % " " % Utils::getTokenName() % ")"; + QString item = i.key() % "(" % QString::number(i.value(), 'g', 8) % " " % Settings::getTokenName() % ")"; ui->inputsCombo->addItem(item); if (item.startsWith(lastFromAddr)) ui->inputsCombo->setCurrentText(item); @@ -756,7 +756,7 @@ void RPC::watchTxStatus() { SentTxStore::addToSentTx(watchingOps.value(id), txid); - main->ui->statusBar->showMessage(Utils::txidStatusMessage + " " + txid); + main->ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); main->loadingLabel->setVisible(false); watchingOps.remove(id); @@ -784,9 +784,9 @@ void RPC::watchTxStatus() { } if (watchingOps.isEmpty()) { - txTimer->start(Utils::updateSpeed); + txTimer->start(Settings::updateSpeed); } else { - txTimer->start(Utils::quickUpdateSpeed); + txTimer->start(Settings::quickUpdateSpeed); } } diff --git a/src/rpc.h b/src/rpc.h index ae2b1ef..607ff15 100644 --- a/src/rpc.h +++ b/src/rpc.h @@ -3,7 +3,6 @@ #include "precompiled.h" -#include "unspentoutput.h" #include "balancestablemodel.h" #include "txtablemodel.h" #include "ui_mainwindow.h" diff --git a/src/sendtab.cpp b/src/sendtab.cpp index ae4e89e..6f0007e 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -5,7 +5,7 @@ #include "ui_memodialog.h" #include "settings.h" #include "rpc.h" -#include "utils.h" + #include "precompiled.h" @@ -71,19 +71,19 @@ void MainWindow::setupSendTab() { QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) { if (pos == 1) { // Set the fees - ui->lblMinerFee->setText(QString::number(Utils::getMinerFee(), 'g', 8) % - " " % Utils::getTokenName()); - ui->lblMinerFeeUSD->setText(Settings::getInstance()->getUSDFormat(Utils::getMinerFee())); + ui->lblMinerFee->setText(QString::number(Settings::getMinerFee(), 'g', 8) % + " " % Settings::getTokenName()); + ui->lblMinerFeeUSD->setText(Settings::getInstance()->getUSDFormat(Settings::getMinerFee())); // Dev Fee. - if (Utils::getDevFee() < 0.0001) { + if (Settings::getDevFee() < 0.0001) { ui->lblDevFee->setText(""); ui->lblDevFeeUSD->setText(""); ui->lblDevFeeTxt->setText(""); } else { - ui->lblDevFee->setText(QString::number(Utils::getDevFee(), 'g', 8) % - " " % Utils::getTokenName()); - ui->lblDevFeeUSD->setText(Settings::getInstance()->getUSDFormat(Utils::getDevFee())); + ui->lblDevFee->setText(QString::number(Settings::getDevFee(), 'g', 8) % + " " % Settings::getTokenName()); + ui->lblDevFeeUSD->setText(Settings::getInstance()->getUSDFormat(Settings::getDevFee())); } // Set focus to the first address box @@ -143,7 +143,7 @@ void MainWindow::setDefaultPayFrom() { void MainWindow::inputComboTextChanged(const QString& text) { auto bal = rpc->getAllBalances()->value(text.split("(")[0].trimmed()); - auto balFmt = QString::number(bal, 'g', 8) + " " % Utils::getTokenName(); + auto balFmt = QString::number(bal, 'g', 8) + " " % Settings::getTokenName(); ui->sendAddressBalance->setText(balFmt); ui->sendAddressBalanceUSD->setText(Settings::getInstance()->getUSDFormat(bal)); @@ -351,7 +351,7 @@ void MainWindow::maxAmountChecked(int checked) { auto amt = ui->sendToWidgets->findChild(QString("Amount") % QString::number(i+1)); sumAllAmounts += amt->text().toDouble(); } - sumAllAmounts += Utils::getTotalFee(); + sumAllAmounts += Settings::getTotalFee(); auto addr = ui->inputsCombo->currentText().split("(")[0]; @@ -384,7 +384,7 @@ Tx MainWindow::createTxFromSendPage() { tx.toAddrs.push_back( ToFields{addr, amt, memo, memo.toUtf8().toHex()} ); } - tx.fee = Utils::getMinerFee(); + tx.fee = Settings::getMinerFee(); return tx; } @@ -503,14 +503,14 @@ bool MainWindow::confirmTx(Tx tx, ToFields devFee) { fee->setObjectName(QStringLiteral("devFee")); fee->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); confirm.gridLayout->addWidget(fee, i+1, 1, 1, 1); - fee ->setText(Settings::getInstance()->getZECDisplayFormat(Utils::getDevFee())); + fee ->setText(Settings::getInstance()->getZECDisplayFormat(Settings::getDevFee())); auto devFeeUSD = new QLabel(confirm.sendToAddrs); devFeeUSD->setSizePolicy(sizePolicy1); devFeeUSD->setObjectName(QStringLiteral("devFeeUSD")); devFeeUSD->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); confirm.gridLayout->addWidget(devFeeUSD, i+1, 2, 1, 1); - devFeeUSD ->setText(Settings::getInstance()->getUSDFormat(Utils::getDevFee())); + devFeeUSD ->setText(Settings::getInstance()->getUSDFormat(Settings::getDevFee())); } } @@ -543,7 +543,7 @@ void MainWindow::sendButton() { return; } - ToFields devFee{ Utils::getDevAddr(tx), Utils::getDevFee(), "", "" }; + ToFields devFee{ Settings::getDevAddr(tx), Settings::getDevFee(), "", "" }; // Show a dialog to confirm the Tx if (confirmTx(tx, devFee)) { diff --git a/src/settings.cpp b/src/settings.cpp index 8ae7502..23abcbd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" -#include "utils.h" +#include "mainwindow.h" #include "settings.h" Settings* Settings::instance = nullptr; @@ -110,7 +110,7 @@ QString Settings::getUSDFormat(double bal) { } QString Settings::getZECDisplayFormat(double bal) { - return QString::number(bal, 'g', 8) % " " % Utils::getTokenName(); + return QString::number(bal, 'g', 8) % " " % Settings::getTokenName(); } QString Settings::getZECUSDDisplayFormat(double bal) { @@ -128,3 +128,76 @@ void Settings::saveRestore(QDialog* d) { QSettings().setValue(d->objectName() % "geometry", d->saveGeometry()); }); } + +//================================= +// Static Stuff +//================================= + +const QString Settings::txidStatusMessage = QString("Tx submitted (right click to copy) txid:"); + +const QString Settings::getTokenName() { + if (Settings::getInstance()->isTestnet()) { + return "TAZ"; + } else { + return "ZEC"; + } +} + +const QString Settings::getDonationAddr(bool sapling) { + if (Settings::getInstance()->isTestnet()) + if (sapling) + return "ztestsapling1wn6889vznyu42wzmkakl2effhllhpe4azhu696edg2x6me4kfsnmqwpglaxzs7tmqsq7kudemp5"; + else + return "ztn6fYKBii4Fp4vbGhkPgrtLU4XjXp4ZBMZgShtopmDGbn1L2JLTYbBp2b7SSkNr9F3rQeNZ9idmoR7s4JCVUZ7iiM5byhF"; + else + if (sapling) + return "zs1gv64eu0v2wx7raxqxlmj354y9ycznwaau9kduljzczxztvs4qcl00kn2sjxtejvrxnkucw5xx9u"; + else + return "zcEgrceTwvoiFdEvPWcsJHAMrpLsprMF6aRJiQa3fan5ZphyXLPuHghnEPrEPRoEVzUy65GnMVyCTRdkT6BYBepnXh6NBYs"; +} + +const QString Settings::getDevSproutAddr() { + return "ztbGDqgkmXQjheivgeirwEvJLD4SUNqsWCGwxwVg4YpGz1ARR8P2rXaptkT14z3NDKamcxNmQuvmvktyokMs7HkutRNSx1D"; +} + +// Get the dev fee address based on the transaction +const QString Settings::getDevAddr(Tx) { + return QString(); +} + + +double Settings::getMinerFee() { + return 0.0001; +} + +double Settings::getZboardAmount() { + return 0.0001; +} + +QString Settings::getZboardAddr() { + if (Settings::getInstance()->isTestnet()) { + return getDonationAddr(true); + } + else { + return "zs10m00rvkhfm4f7n23e4sxsx275r7ptnggx39ygl0vy46j9mdll5c97gl6dxgpk0njuptg2mn9w5s"; + } +} +double Settings::getDevFee() { + if (Settings::getInstance()->isTestnet()) { + return 0; + } else { + return 0; + } +} + +double Settings::getTotalFee() { return getMinerFee() + getDevFee(); } + +bool Settings::isValidAddress(QString addr) { + QRegExp zcexp("^z[a-z0-9]{94}$", Qt::CaseInsensitive); + QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive); + QRegExp ztsexp("^ztestsapling[a-z0-9]{76}", Qt::CaseInsensitive); + QRegExp texp("^t[a-z0-9]{34}$", Qt::CaseInsensitive); + + return zcexp.exactMatch(addr) || texp.exactMatch(addr) || + ztsexp.exactMatch(addr) || zsexp.exactMatch(addr); +} diff --git a/src/settings.h b/src/settings.h index b13586f..d7cd329 100644 --- a/src/settings.h +++ b/src/settings.h @@ -10,6 +10,9 @@ struct Config { QString rpcpassword; }; +struct ToFields; +struct Tx; + class Settings { public: @@ -55,6 +58,26 @@ public: QString getZECDisplayFormat (double bal); QString getZECUSDDisplayFormat(double bal); + // Static stuff + static const QString txidStatusMessage; + + static const QString getTokenName(); + static const QString getDevSproutAddr(); + static const QString getDevAddr(Tx tx); + static const QString getDonationAddr(bool sapling); + + static double getMinerFee(); + static double getZboardAmount(); + static QString getZboardAddr(); + static double getDevFee(); + static double getTotalFee(); + + static bool isValidAddress(QString addr); + + static const int updateSpeed = 20 * 1000; // 20 sec + static const int quickUpdateSpeed = 5 * 1000; // 5 sec + static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr + private: // This class can only be accessed through Settings::getInstance() Settings() = default; diff --git a/src/turnstile.cpp b/src/turnstile.cpp index 64ec6e0..bf512e1 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -1,8 +1,8 @@ #include "turnstile.h" #include "mainwindow.h" -#include "unspentoutput.h" +#include "balancestablemodel.h" #include "rpc.h" -#include "utils.h" + #include "settings.h" #include "precompiled.h" @@ -167,7 +167,7 @@ QList Turnstile::splitAmount(double amount, int parts) { } // Add the Tx fees - sumofparts += amounts.size() * Utils::getMinerFee(); + sumofparts += amounts.size() * Settings::getMinerFee(); //qDebug() << QString::number(sumofparts, 'f', 8) << QString::number(amount, 'f', 8); //Q_ASSERT(QString::number(sumofparts, 'f', 8) == QString::number(amount, 'f', 8)); @@ -177,7 +177,7 @@ QList Turnstile::splitAmount(double amount, int parts) { void Turnstile::fillAmounts(QList& amounts, double amount, int count) { if (count == 1 || amount < 0.01) { // Also account for the fees needed to send all these transactions - auto actual = amount - (Utils::getMinerFee() * (amounts.size() + 1)); + auto actual = amount - (Settings::getMinerFee() * (amounts.size() + 1)); amounts.push_back(actual); return; @@ -297,14 +297,14 @@ void Turnstile::executeMigrationStep() { // If this is the last step, then send the remaining amount instead of the actual amount. if (lastStep) { - auto remainingAmount = balance - Utils::getMinerFee(); + auto remainingAmount = balance - Settings::getMinerFee(); if (remainingAmount > 0) { to.amount = remainingAmount; } } // Create the Tx - auto tx = Tx{ nextStep->fromAddr, { to }, Utils::getMinerFee() }; + auto tx = Tx{ nextStep->fromAddr, { to }, Settings::getMinerFee() }; // And send it doSendTx(tx, [=] () { @@ -328,7 +328,7 @@ void Turnstile::executeMigrationStep() { // Send it to the final destination address. auto bal = rpc->getAllBalances()->value(nextStep->intTAddr); - auto sendAmt = bal - Utils::getMinerFee(); + auto sendAmt = bal - Settings::getMinerFee(); if (sendAmt < 0) { qDebug() << "Not enough balance!." << bal << ":" << sendAmt; @@ -340,7 +340,7 @@ void Turnstile::executeMigrationStep() { QList to = { ToFields{ nextStep->destAddr, sendAmt, "", "" } }; // Create the Tx - auto tx = Tx{ nextStep->intTAddr, to, Utils::getMinerFee() }; + auto tx = Tx{ nextStep->intTAddr, to, Settings::getMinerFee() }; // And send it doSendTx(tx, [=] () { diff --git a/src/txtablemodel.cpp b/src/txtablemodel.cpp index bc49bf6..f70e220 100644 --- a/src/txtablemodel.cpp +++ b/src/txtablemodel.cpp @@ -1,6 +1,6 @@ #include "txtablemodel.h" #include "settings.h" -#include "utils.h" + #include "rpc.h" TxTableModel::TxTableModel(QObject *parent) diff --git a/src/unspentoutput.cpp b/src/unspentoutput.cpp deleted file mode 100644 index 7b3a2d6..0000000 --- a/src/unspentoutput.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "unspentoutput.h" diff --git a/src/unspentoutput.h b/src/unspentoutput.h deleted file mode 100644 index e106e5d..0000000 --- a/src/unspentoutput.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef UNSPENTOUTPUT_H -#define UNSPENTOUTPUT_H - -#include "precompiled.h" - -struct UnspentOutput { - QString address; - QString txid; - QString amount; - int confirmations; - bool spendable; -}; - - -#endif // UNSPENTOUTPUT_H diff --git a/src/utils.cpp b/src/utils.cpp deleted file mode 100644 index 7f638fb..0000000 --- a/src/utils.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "utils.h" -#include "settings.h" -#include "mainwindow.h" - -const QString Utils::txidStatusMessage = QString("Tx submitted (right click to copy) txid:"); - -const QString Utils::getTokenName() { - if (Settings::getInstance()->isTestnet()) { - return "TAZ"; - } else { - return "ZEC"; - } -} - -const QString Utils::getDonationAddr(bool sapling) { - if (Settings::getInstance()->isTestnet()) - if (sapling) - return "ztestsapling1wn6889vznyu42wzmkakl2effhllhpe4azhu696edg2x6me4kfsnmqwpglaxzs7tmqsq7kudemp5"; - else - return "ztn6fYKBii4Fp4vbGhkPgrtLU4XjXp4ZBMZgShtopmDGbn1L2JLTYbBp2b7SSkNr9F3rQeNZ9idmoR7s4JCVUZ7iiM5byhF"; - else - if (sapling) - return "zs1gv64eu0v2wx7raxqxlmj354y9ycznwaau9kduljzczxztvs4qcl00kn2sjxtejvrxnkucw5xx9u"; - else - return "zcEgrceTwvoiFdEvPWcsJHAMrpLsprMF6aRJiQa3fan5ZphyXLPuHghnEPrEPRoEVzUy65GnMVyCTRdkT6BYBepnXh6NBYs"; -} - -const QString Utils::getDevSproutAddr() { - return "ztbGDqgkmXQjheivgeirwEvJLD4SUNqsWCGwxwVg4YpGz1ARR8P2rXaptkT14z3NDKamcxNmQuvmvktyokMs7HkutRNSx1D"; -} - -// Get the dev fee address based on the transaction -const QString Utils::getDevAddr(Tx) { - return QString(); -} - - -double Utils::getMinerFee() { - return 0.0001; -} - -double Utils::getZboardAmount() { - return 0.0001; -} - -QString Utils::getZboardAddr() { - if (Settings::getInstance()->isTestnet()) { - return getDonationAddr(true); - } - else { - return "zs10m00rvkhfm4f7n23e4sxsx275r7ptnggx39ygl0vy46j9mdll5c97gl6dxgpk0njuptg2mn9w5s"; - } -} -double Utils::getDevFee() { - if (Settings::getInstance()->isTestnet()) { - return 0; - } else { - return 0; - } -} - -double Utils::getTotalFee() { return getMinerFee() + getDevFee(); } - -bool Utils::isValidAddress(QString addr) { - QRegExp zcexp("^z[a-z0-9]{94}$", Qt::CaseInsensitive); - QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive); - QRegExp ztsexp("^ztestsapling[a-z0-9]{76}", Qt::CaseInsensitive); - QRegExp texp("^t[a-z0-9]{34}$", Qt::CaseInsensitive); - - return zcexp.exactMatch(addr) || texp.exactMatch(addr) || - ztsexp.exactMatch(addr) || zsexp.exactMatch(addr); -} diff --git a/src/utils.h b/src/utils.h deleted file mode 100644 index d7f9796..0000000 --- a/src/utils.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H - -#include "precompiled.h" - -struct ToFields; -struct Tx; - -class Utils -{ -public: - static const QString txidStatusMessage; - - static const QString getTokenName(); - static const QString getDevSproutAddr(); - static const QString getDevAddr(Tx tx); - static const QString getDonationAddr(bool sapling); - - static double getMinerFee(); - static double getZboardAmount(); - static QString getZboardAddr(); - static double getDevFee(); - static double getTotalFee(); - - static bool isValidAddress(QString addr); - - static const int updateSpeed = 20 * 1000; // 20 sec - static const int quickUpdateSpeed = 5 * 1000; // 5 sec - static const int priceRefreshSpeed = 60 * 60 * 1000; // 1 hr -private: - Utils() = delete; -}; - -#endif // UTILS_H \ No newline at end of file diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index be1c031..87cea74 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -42,7 +42,6 @@ SOURCES += \ src/mainwindow.cpp \ src/rpc.cpp \ src/balancestablemodel.cpp \ - src/unspentoutput.cpp \ src/3rdparty/qrcode/BitBuffer.cpp \ src/3rdparty/qrcode/QrCode.cpp \ src/3rdparty/qrcode/QrSegment.cpp \ @@ -51,7 +50,6 @@ SOURCES += \ src/senttxstore.cpp \ src/txtablemodel.cpp \ src/turnstile.cpp \ - src/utils.cpp \ src/qrcodelabel.cpp \ src/connection.cpp \ src/fillediconlabel.cpp \ @@ -62,7 +60,6 @@ HEADERS += \ src/precompiled.h \ src/rpc.h \ src/balancestablemodel.h \ - src/unspentoutput.h \ src/3rdparty/qrcode/BitBuffer.hpp \ src/3rdparty/qrcode/QrCode.hpp \ src/3rdparty/qrcode/QrSegment.hpp \ @@ -71,7 +68,6 @@ HEADERS += \ src/txtablemodel.h \ src/senttxstore.h \ src/turnstile.h \ - src/utils.h \ src/qrcodelabel.h \ src/connection.h \ src/fillediconlabel.h \