Add custom fee to gui
This commit is contained in:
@@ -221,6 +221,7 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx, bool isChatMessage
|
||||
json rec = json::object();
|
||||
rec["address"] = toAddr.addr.toStdString();
|
||||
rec["amount"] = toAddr.amount.toqint64();
|
||||
rec["fee"] = tx.fee.toqint64();
|
||||
if (Settings::isZAddress(toAddr.addr) && !toAddr.memo.trimmed().isEmpty())
|
||||
rec["memo"] = toAddr.memo.toStdString();
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ private:
|
||||
|
||||
void addAddressSection();
|
||||
void maxAmountChecked(int checked);
|
||||
void toggleMinerFeeEditable(int state);
|
||||
|
||||
void editSchedule();
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>5</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_6">
|
||||
<attribute name="title">
|
||||
@@ -93,6 +93,7 @@
|
||||
<widget class="QLabel" name="contactNameMemo">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -737,6 +738,7 @@
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -749,6 +751,7 @@
|
||||
<widget class="QLabel" name="balTotal">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -877,8 +880,8 @@
|
||||
<attribute name="title">
|
||||
<string>Send</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
@@ -907,6 +910,7 @@
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -945,7 +949,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Send To</string>
|
||||
@@ -979,8 +983,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1301</width>
|
||||
<height>493</height>
|
||||
<width>1331</width>
|
||||
<height>527</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="sendToLayout">
|
||||
@@ -1163,24 +1167,27 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutSendRecurring">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="customFee">
|
||||
<property name="text">
|
||||
<string>Use custom Fee</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1198</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="minerFeeLabel">
|
||||
@@ -1972,7 +1979,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1379</width>
|
||||
<height>24</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
||||
@@ -31,6 +31,9 @@ void MainWindow::setupSendTab() {
|
||||
// Max available Checkbox
|
||||
QObject::connect(ui->Max1, &QCheckBox::stateChanged, this, &MainWindow::maxAmountChecked);
|
||||
|
||||
//Custom Fee Checkbox
|
||||
QObject::connect(ui->customFee, &QCheckBox::stateChanged, this, &MainWindow::toggleMinerFeeEditable);
|
||||
|
||||
// The first Address button
|
||||
QObject::connect(ui->Address1, &QLineEdit::textChanged, [=] (auto text) {
|
||||
this->addressChanged(1, text);
|
||||
@@ -57,8 +60,8 @@ void MainWindow::setupSendTab() {
|
||||
this->amountChanged(1, text);
|
||||
});
|
||||
|
||||
// Fee amount changed
|
||||
ui->minerFeeAmt->setReadOnly(true);
|
||||
// Fee amount changed
|
||||
QObject::connect(ui->minerFeeAmt, &QLineEdit::textChanged, [=](auto txt) {
|
||||
CAmount fee = CAmount::fromDecimalString(txt);
|
||||
|
||||
@@ -520,7 +523,6 @@ Tx MainWindow::createTxFromSendPage() {
|
||||
|
||||
CAmount amt;
|
||||
|
||||
|
||||
// Make sure it parses
|
||||
amtStr.toDouble(&ok);
|
||||
if (!ok) {
|
||||
@@ -534,16 +536,21 @@ Tx MainWindow::createTxFromSendPage() {
|
||||
|
||||
QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
|
||||
|
||||
|
||||
|
||||
tx.toAddrs.push_back( ToFields{addr, amt, memo} );
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Allow Custom Fee in SendTab
|
||||
bool customFee = ui->customFee->isChecked();
|
||||
|
||||
|
||||
tx.fee = Settings::getMinerFee();
|
||||
CAmount fee ;
|
||||
if (customFee) {
|
||||
QString feeStr = ui->minerFeeAmt->text();
|
||||
tx.fee = CAmount::fromDecimalString(feeStr);
|
||||
}else{
|
||||
tx.fee = Settings::getMinerFee();
|
||||
}
|
||||
|
||||
return tx;
|
||||
}
|
||||
@@ -797,11 +804,20 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) {
|
||||
confirm.lblRecurringDesc->setText(rpi->getScheduleDescription());
|
||||
}
|
||||
|
||||
CAmount defaultFee = Settings::getMinerFee();
|
||||
if (tx.fee.toDecimalString() != defaultFee.toDecimalString() ) {
|
||||
auto customFeeWarning = new QLabel(confirm.sendToAddrs);
|
||||
customFeeWarning->setObjectName(QStringLiteral("Custom Fee"));
|
||||
customFeeWarning->setText(tr("You are using a custom Fee"));
|
||||
customFeeWarning->setStyleSheet("color: red;");
|
||||
confirm.gridLayout->addWidget(customFeeWarning);
|
||||
confirm.gridLayout->rowStretch(1);
|
||||
row++;
|
||||
}
|
||||
|
||||
// Syncing warning
|
||||
confirm.syncingWarning->setVisible(Settings::getInstance()->isSyncing());
|
||||
|
||||
|
||||
|
||||
// Show the dialog and submit it if the user confirms
|
||||
return d.exec() == QDialog::Accepted;
|
||||
}
|
||||
@@ -956,9 +972,24 @@ QString MainWindow::doSendTxValidations(Tx tx) {
|
||||
.arg(available.toDecimalhushString(), total.toDecimalhushString());
|
||||
}
|
||||
|
||||
if (total == 0) {
|
||||
return tr("Value or fee must be > 0\n\nValue and fee cannot both be 0.");
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void MainWindow::cancelButton() {
|
||||
clearSendForm();
|
||||
}
|
||||
|
||||
//Check for custom fee checkbox
|
||||
void MainWindow::toggleMinerFeeEditable(int state) {
|
||||
if (state == Qt::Checked) {
|
||||
ui->minerFeeAmt->setReadOnly(false);
|
||||
} else {
|
||||
ui->minerFeeAmt->setReadOnly(true);
|
||||
ui->minerFeeAmt->setText(Settings::getMinerFee().toDecimalString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user