Add dev fee for testnet
This commit is contained in:
@@ -39,6 +39,16 @@
|
|||||||
<string>To</string>
|
<string>To</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="minerFee">
|
||||||
|
<property name="text">
|
||||||
|
<string>Miner Amount</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="Addr1">
|
<widget class="QLabel" name="Addr1">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -66,6 +76,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="labelMinerFee">
|
||||||
|
<property name="text">
|
||||||
|
<string>Miner Fee</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="labelDevFee">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dev Fee</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="devFee">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dev Fee Amount</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -89,13 +123,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="feesLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ void MainWindow::setupSendTab() {
|
|||||||
QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) {
|
QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) {
|
||||||
if (pos == 1) {
|
if (pos == 1) {
|
||||||
// Set the fees
|
// Set the fees
|
||||||
ui->sendTxFees->setText("0.0001 " + Utils::getTokenName());
|
ui->sendTxFees->setText(QString::number(Utils::getTotalFee(), 'g', 8) %
|
||||||
|
" " % Utils::getTokenName());
|
||||||
|
|
||||||
// Set focus to the first address box
|
// Set focus to the first address box
|
||||||
ui->Address1->setFocus();
|
ui->Address1->setFocus();
|
||||||
@@ -221,7 +222,7 @@ void MainWindow::maxAmountChecked(int checked) {
|
|||||||
auto amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1));
|
auto amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1));
|
||||||
sumAllAmounts += amt->text().toDouble();
|
sumAllAmounts += amt->text().toDouble();
|
||||||
}
|
}
|
||||||
sumAllAmounts += settings->fees();
|
sumAllAmounts += Utils::getTotalFee();
|
||||||
|
|
||||||
auto addr = ui->inputsCombo->currentText().split("(")[0];
|
auto addr = ui->inputsCombo->currentText().split("(")[0];
|
||||||
|
|
||||||
@@ -276,6 +277,8 @@ void MainWindow::sendButton() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto devAddress = Utils::getDevAddr(fromAddr, toAddrs);
|
||||||
|
|
||||||
// Get all the addresses and amounts
|
// Get all the addresses and amounts
|
||||||
json allRecepients = json::array();
|
json allRecepients = json::array();
|
||||||
|
|
||||||
@@ -336,6 +339,28 @@ void MainWindow::sendButton() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the dev fee to the transaction
|
||||||
|
if (!devAddress.isEmpty() && Utils::getDevFee() > 0) {
|
||||||
|
json devFee = json::object();
|
||||||
|
devFee["address"] = devAddress.toStdString();
|
||||||
|
devFee["amount"] = Utils::getDevFee();
|
||||||
|
allRecepients.push_back(devFee);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add two rows for fees
|
||||||
|
{
|
||||||
|
confirm.labelMinerFee->setText("Miner Fee");
|
||||||
|
confirm.minerFee->setText(QString::number(Utils::getMinerFee(), 'g', 8) % " " % Utils::getTokenName());
|
||||||
|
|
||||||
|
if (!devAddress.isEmpty() && Utils::getDevFee() > 0) {
|
||||||
|
confirm.labelDevFee->setText("Dev Fee");
|
||||||
|
confirm.devFee->setText(QString::number(Utils::getMinerFee(), 'g', 8) % " " % Utils::getTokenName());
|
||||||
|
} else {
|
||||||
|
confirm.labelDevFee->setText("");
|
||||||
|
confirm.devFee->setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add sender
|
// Add sender
|
||||||
json params = json::array();
|
json params = json::array();
|
||||||
params.push_back(fromAddr.toStdString());
|
params.push_back(fromAddr.toStdString());
|
||||||
@@ -344,9 +369,6 @@ void MainWindow::sendButton() {
|
|||||||
// And show it in the confirm dialog
|
// And show it in the confirm dialog
|
||||||
confirm.sendFrom->setText(fnSplitAddressForWrap(fromAddr));
|
confirm.sendFrom->setText(fnSplitAddressForWrap(fromAddr));
|
||||||
|
|
||||||
// Fees in the confirm dialog
|
|
||||||
confirm.feesLabel->setText("Fee 0.0001 " % Utils::getTokenName());
|
|
||||||
|
|
||||||
// Show the dialog and submit it if the user confirms
|
// Show the dialog and submit it if the user confirms
|
||||||
if (d.exec() == QDialog::Accepted) {
|
if (d.exec() == QDialog::Accepted) {
|
||||||
rpc->sendZTransaction(params, [=](const json& reply) {
|
rpc->sendZTransaction(params, [=](const json& reply) {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ public:
|
|||||||
QString getHost();
|
QString getHost();
|
||||||
QString getPort();
|
QString getPort();
|
||||||
|
|
||||||
double fees() { return 0.0001; }
|
|
||||||
bool loadFromSettings();
|
bool loadFromSettings();
|
||||||
bool loadFromFile();
|
bool loadFromFile();
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,15 @@ public:
|
|||||||
QLabel *sendFrom;
|
QLabel *sendFrom;
|
||||||
QGroupBox *sendToAddrs;
|
QGroupBox *sendToAddrs;
|
||||||
QGridLayout *gridLayout;
|
QGridLayout *gridLayout;
|
||||||
|
QLabel *minerFee;
|
||||||
QLabel *Addr1;
|
QLabel *Addr1;
|
||||||
QLabel *Amt1;
|
QLabel *Amt1;
|
||||||
QLabel *Memo1;
|
QLabel *Memo1;
|
||||||
|
QLabel *labelMinerFee;
|
||||||
|
QLabel *labelDevFee;
|
||||||
|
QLabel *devFee;
|
||||||
QSpacerItem *verticalSpacer;
|
QSpacerItem *verticalSpacer;
|
||||||
QFrame *line;
|
QFrame *line;
|
||||||
QLabel *feesLabel;
|
|
||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
|
|
||||||
void setupUi(QDialog *confirm)
|
void setupUi(QDialog *confirm)
|
||||||
@@ -63,6 +66,12 @@ public:
|
|||||||
sendToAddrs->setObjectName(QStringLiteral("sendToAddrs"));
|
sendToAddrs->setObjectName(QStringLiteral("sendToAddrs"));
|
||||||
gridLayout = new QGridLayout(sendToAddrs);
|
gridLayout = new QGridLayout(sendToAddrs);
|
||||||
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
||||||
|
minerFee = new QLabel(sendToAddrs);
|
||||||
|
minerFee->setObjectName(QStringLiteral("minerFee"));
|
||||||
|
minerFee->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
gridLayout->addWidget(minerFee, 2, 1, 1, 1);
|
||||||
|
|
||||||
Addr1 = new QLabel(sendToAddrs);
|
Addr1 = new QLabel(sendToAddrs);
|
||||||
Addr1->setObjectName(QStringLiteral("Addr1"));
|
Addr1->setObjectName(QStringLiteral("Addr1"));
|
||||||
Addr1->setWordWrap(true);
|
Addr1->setWordWrap(true);
|
||||||
@@ -80,6 +89,22 @@ public:
|
|||||||
|
|
||||||
gridLayout->addWidget(Memo1, 1, 0, 1, 2);
|
gridLayout->addWidget(Memo1, 1, 0, 1, 2);
|
||||||
|
|
||||||
|
labelMinerFee = new QLabel(sendToAddrs);
|
||||||
|
labelMinerFee->setObjectName(QStringLiteral("labelMinerFee"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(labelMinerFee, 2, 0, 1, 1);
|
||||||
|
|
||||||
|
labelDevFee = new QLabel(sendToAddrs);
|
||||||
|
labelDevFee->setObjectName(QStringLiteral("labelDevFee"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(labelDevFee, 3, 0, 1, 1);
|
||||||
|
|
||||||
|
devFee = new QLabel(sendToAddrs);
|
||||||
|
devFee->setObjectName(QStringLiteral("devFee"));
|
||||||
|
devFee->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
gridLayout->addWidget(devFee, 3, 1, 1, 1);
|
||||||
|
|
||||||
|
|
||||||
verticalLayout->addWidget(sendToAddrs);
|
verticalLayout->addWidget(sendToAddrs);
|
||||||
|
|
||||||
@@ -94,11 +119,6 @@ public:
|
|||||||
|
|
||||||
verticalLayout->addWidget(line);
|
verticalLayout->addWidget(line);
|
||||||
|
|
||||||
feesLabel = new QLabel(confirm);
|
|
||||||
feesLabel->setObjectName(QStringLiteral("feesLabel"));
|
|
||||||
|
|
||||||
verticalLayout->addWidget(feesLabel);
|
|
||||||
|
|
||||||
buttonBox = new QDialogButtonBox(confirm);
|
buttonBox = new QDialogButtonBox(confirm);
|
||||||
buttonBox->setObjectName(QStringLiteral("buttonBox"));
|
buttonBox->setObjectName(QStringLiteral("buttonBox"));
|
||||||
buttonBox->setOrientation(Qt::Horizontal);
|
buttonBox->setOrientation(Qt::Horizontal);
|
||||||
@@ -120,10 +140,13 @@ public:
|
|||||||
groupBox->setTitle(QApplication::translate("confirm", "From", nullptr));
|
groupBox->setTitle(QApplication::translate("confirm", "From", nullptr));
|
||||||
sendFrom->setText(QString());
|
sendFrom->setText(QString());
|
||||||
sendToAddrs->setTitle(QApplication::translate("confirm", "To", nullptr));
|
sendToAddrs->setTitle(QApplication::translate("confirm", "To", nullptr));
|
||||||
|
minerFee->setText(QApplication::translate("confirm", "Miner Amount", nullptr));
|
||||||
Addr1->setText(QApplication::translate("confirm", "TextLabel", nullptr));
|
Addr1->setText(QApplication::translate("confirm", "TextLabel", nullptr));
|
||||||
Amt1->setText(QApplication::translate("confirm", "TextLabel", nullptr));
|
Amt1->setText(QApplication::translate("confirm", "TextLabel", nullptr));
|
||||||
Memo1->setText(QApplication::translate("confirm", "TextLabel", nullptr));
|
Memo1->setText(QApplication::translate("confirm", "TextLabel", nullptr));
|
||||||
feesLabel->setText(QString());
|
labelMinerFee->setText(QApplication::translate("confirm", "Miner Fee", nullptr));
|
||||||
|
labelDevFee->setText(QApplication::translate("confirm", "Dev Fee", nullptr));
|
||||||
|
devFee->setText(QApplication::translate("confirm", "Dev Fee Amount", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
const QString Utils::txidStatusMessage = QString("Tx submitted (right click to copy) txid:");
|
const QString Utils::txidStatusMessage = QString("Tx submitted (right click to copy) txid:");
|
||||||
|
|
||||||
@@ -10,3 +11,50 @@ const QString Utils::getTokenName() {
|
|||||||
return "ZEC";
|
return "ZEC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the dev fee address based on the transaction
|
||||||
|
const QString Utils::getDevAddr(const QString& fromAddr, const QList<ToFields>& toAddrs) {
|
||||||
|
auto testnetAddrLookup = [=] (const QString& addr) -> QString {
|
||||||
|
if (addr.startsWith("ztestsapling")) {
|
||||||
|
return "ztestsapling1kdp74adyfsmm9838jaupgfyx3npgw8ut63stjjx757pc248cuc0ymzphqeux60c64qe5qt68ygh";
|
||||||
|
} else if (addr.startsWith("zt")) {
|
||||||
|
return "ztbGDqgkmXQjheivgeirwEvJLD4SUNqsWCGwxwVg4YpGz1ARR8P2rXaptkT14z3NDKamcxNmQuvmvktyokMs7HkutRNSx1D";
|
||||||
|
} else {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Settings::getInstance()->isTestnet()) {
|
||||||
|
auto devAddr = testnetAddrLookup(fromAddr);
|
||||||
|
if (!devAddr.isEmpty()) {
|
||||||
|
return devAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// t-Addr, find if it is going to a sprout or sapling address
|
||||||
|
for (const ToFields& to : toAddrs) {
|
||||||
|
devAddr = testnetAddrLookup(to.addr);
|
||||||
|
if (!devAddr.isEmpty()) {
|
||||||
|
return devAddr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is a t-Addr -> t-Addr transaction, use the sapling address by default
|
||||||
|
return testnetAddrLookup("ztestsapling");
|
||||||
|
} else {
|
||||||
|
// Mainnet doesn't have a fee yet!
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double Utils::getMinerFee() {
|
||||||
|
return 0.0001;
|
||||||
|
}
|
||||||
|
double Utils::getDevFee() {
|
||||||
|
if (Settings::getInstance()->isTestnet()) {
|
||||||
|
return 0.0001;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double Utils::getTotalFee() { return getMinerFee() + getDevFee(); }
|
||||||
@@ -3,12 +3,19 @@
|
|||||||
|
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
|
struct ToFields;
|
||||||
|
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const QString txidStatusMessage;
|
static const QString txidStatusMessage;
|
||||||
|
|
||||||
static const QString getTokenName();
|
static const QString getTokenName();
|
||||||
|
static const QString getDevAddr(const QString& fromAddr, const QList<ToFields>& toAddrs);
|
||||||
|
|
||||||
|
static double getMinerFee();
|
||||||
|
static double getDevFee();
|
||||||
|
static double getTotalFee();
|
||||||
|
|
||||||
static const int updateSpeed = 20 * 1000; // 20 sec
|
static const int updateSpeed = 20 * 1000; // 20 sec
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user