Custom fees
This commit is contained in:
@@ -503,23 +503,29 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="minerFeeLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Miner Fee:</string>
|
<string>Miner Fee</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lblMinerFee">
|
<widget class="QLineEdit" name="minerFeeAmt">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>0</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="lblMinerFeeUSD">
|
<widget class="QLabel" name="lblMinerFeeUSD">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string> </string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -326,6 +326,8 @@ void RPC::fillTxJsonParams(json& params, Tx tx) {
|
|||||||
// Add sender
|
// Add sender
|
||||||
params.push_back(tx.fromAddr.toStdString());
|
params.push_back(tx.fromAddr.toStdString());
|
||||||
params.push_back(allRecepients);
|
params.push_back(allRecepients);
|
||||||
|
params.push_back(1); // minconf
|
||||||
|
params.push_back(QString::number(tx.fee, 'f', 8).toDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,29 +56,30 @@ void MainWindow::setupSendTab() {
|
|||||||
AddressBook::open(this, ui->Address1);
|
AddressBook::open(this, ui->Address1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// The first Amount button
|
// The first Amount button
|
||||||
QObject::connect(ui->Amount1, &QLineEdit::textChanged, [=] (auto text) {
|
QObject::connect(ui->Amount1, &QLineEdit::textChanged, [=] (auto text) {
|
||||||
this->amountChanged(1, text);
|
this->amountChanged(1, text);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fee amount changed
|
||||||
|
QObject::connect(ui->minerFeeAmt, &QLineEdit::textChanged, [=](auto txt) {
|
||||||
|
ui->lblMinerFeeUSD->setText(Settings::getUSDFormat(txt.toDouble()));
|
||||||
|
});
|
||||||
|
ui->minerFeeAmt->setText(Settings::getDecimalString(Settings::getMinerFee()));
|
||||||
|
|
||||||
|
// Set up focus enter to set fees
|
||||||
|
QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) {
|
||||||
|
if (pos == 1) {
|
||||||
|
QString txt = ui->minerFeeAmt->text();
|
||||||
|
ui->lblMinerFeeUSD->setText(Settings::getUSDFormat(txt.toDouble()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Font for the first Memo label
|
// Font for the first Memo label
|
||||||
QFont f = ui->Address1->font();
|
QFont f = ui->Address1->font();
|
||||||
f.setPointSize(f.pointSize() - 1);
|
f.setPointSize(f.pointSize() - 1);
|
||||||
ui->MemoTxt1->setFont(f);
|
ui->MemoTxt1->setFont(f);
|
||||||
|
|
||||||
// Set up focus enter to set fees
|
|
||||||
QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) {
|
|
||||||
if (pos == 1) {
|
|
||||||
// Set the fees
|
|
||||||
ui->lblMinerFee->setText(QString::number(Settings::getMinerFee(), 'g', 8) %
|
|
||||||
" " % Settings::getTokenName());
|
|
||||||
ui->lblMinerFeeUSD->setText(Settings::getUSDFormat(Settings::getMinerFee()));
|
|
||||||
|
|
||||||
// Set focus to the first address box
|
|
||||||
ui->Address1->setFocus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateLabelsAutoComplete() {
|
void MainWindow::updateLabelsAutoComplete() {
|
||||||
@@ -318,6 +319,9 @@ void MainWindow::removeExtraAddresses() {
|
|||||||
// Disable first memo btn
|
// Disable first memo btn
|
||||||
setMemoEnabled(1, false);
|
setMemoEnabled(1, false);
|
||||||
|
|
||||||
|
// Reset the fee
|
||||||
|
ui->minerFeeAmt->setText(Settings::getDecimalString(Settings::getMinerFee()));
|
||||||
|
|
||||||
// Start the deletion after the first item, since we want to keep 1 send field there all there
|
// Start the deletion after the first item, since we want to keep 1 send field there all there
|
||||||
for (int i=1; i < totalItems; i++) {
|
for (int i=1; i < totalItems; i++) {
|
||||||
auto addressGroupBox = ui->sendToWidgets->findChild<QGroupBox*>(QString("AddressGroupBox") % QString::number(i+1));
|
auto addressGroupBox = ui->sendToWidgets->findChild<QGroupBox*>(QString("AddressGroupBox") % QString::number(i+1));
|
||||||
@@ -374,7 +378,7 @@ Tx MainWindow::createTxFromSendPage() {
|
|||||||
tx.toAddrs.push_back( ToFields{addr, amt, memo, memo.toUtf8().toHex()} );
|
tx.toAddrs.push_back( ToFields{addr, amt, memo, memo.toUtf8().toHex()} );
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.fee = Settings::getMinerFee();
|
tx.fee = ui->minerFeeAmt->text().toDouble();
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,14 +109,18 @@ QString Settings::getUSDFormat(double bal) {
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getZECDisplayFormat(double bal) {
|
QString Settings::getDecimalString(double amt) {
|
||||||
// This is idiotic. Why doesn't QString have a way to do this?
|
QString f = QString::number(amt, 'f', 8);
|
||||||
QString f = QString::number(bal, 'f', 8);
|
|
||||||
while (f.contains(".") && (f.right(1) == "0" || f.right(1) == ".")) {
|
while (f.contains(".") && (f.right(1) == "0" || f.right(1) == ".")) {
|
||||||
f = f.left(f.length() - 1);
|
f = f.left(f.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return f % " " % Settings::getTokenName();
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Settings::getZECDisplayFormat(double bal) {
|
||||||
|
// This is idiotic. Why doesn't QString have a way to do this?
|
||||||
|
return getDecimalString(bal) % " " % Settings::getTokenName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getZECUSDDisplayFormat(double bal) {
|
QString Settings::getZECUSDDisplayFormat(double bal) {
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public:
|
|||||||
// Static stuff
|
// Static stuff
|
||||||
static const QString txidStatusMessage;
|
static const QString txidStatusMessage;
|
||||||
|
|
||||||
|
static QString getDecimalString(double amt);
|
||||||
static QString getUSDFormat(double bal);
|
static QString getUSDFormat(double bal);
|
||||||
static QString getZECDisplayFormat(double bal);
|
static QString getZECDisplayFormat(double bal);
|
||||||
static QString getZECUSDDisplayFormat(double bal);
|
static QString getZECUSDDisplayFormat(double bal);
|
||||||
|
|||||||
Reference in New Issue
Block a user