Browse Source

cleanup

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
94bfcd50fc
  1. 6
      src/addressbook.cpp
  2. 2
      src/balancestablemodel.cpp
  3. 10
      src/balancestablemodel.h
  4. 15
      src/connection.cpp
  5. 20
      src/mainwindow.cpp
  6. 16
      src/rpc.cpp
  7. 1
      src/rpc.h
  8. 28
      src/sendtab.cpp
  9. 77
      src/settings.cpp
  10. 23
      src/settings.h
  11. 16
      src/turnstile.cpp
  12. 2
      src/txtablemodel.cpp
  13. 1
      src/unspentoutput.cpp
  14. 15
      src/unspentoutput.h
  15. 72
      src/utils.cpp
  16. 34
      src/utils.h
  17. 4
      zec-qt-wallet.pro

6
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());

2
src/balancestablemodel.cpp

@ -1,6 +1,6 @@
#include "balancestablemodel.h"
#include "settings.h"
#include "utils.h"
BalancesTableModel::BalancesTableModel(QObject *parent)
: QAbstractTableModel(parent) {

10
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:

15
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<int, QProcess::ExitStatus>::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<void(json)>& cb,
const std::function<void(QNetworkReply*, const json&)>& 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<void(json)>& cb,
QObject::connect(reply, &QNetworkReply::finished, [=] {
reply->deleteLater();
if (shutdownInProgress) {
qDebug() << "Ignoring callback because shutdown in progress";
// Ignoring callback because shutdown in progress
return;
}

20
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<int>::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<QString, QString> 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<QString, QString> 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);

16
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);
}
}

1
src/rpc.h

@ -3,7 +3,6 @@
#include "precompiled.h"
#include "unspentoutput.h"
#include "balancestablemodel.h"
#include "txtablemodel.h"
#include "ui_mainwindow.h"

28
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<QLineEdit*>(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)) {

77
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);
}

23
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;

16
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<double> 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<double> Turnstile::splitAmount(double amount, int parts) {
void Turnstile::fillAmounts(QList<double>& 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<ToFields> 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, [=] () {

2
src/txtablemodel.cpp

@ -1,6 +1,6 @@
#include "txtablemodel.h"
#include "settings.h"
#include "utils.h"
#include "rpc.h"
TxTableModel::TxTableModel(QObject *parent)

1
src/unspentoutput.cpp

@ -1 +0,0 @@
#include "unspentoutput.h"

15
src/unspentoutput.h

@ -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

72
src/utils.cpp

@ -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);
}

34
src/utils.h

@ -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

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

Loading…
Cancel
Save