Browse Source

Add custom fee to gui

pull/146/head
lucretius 3 months ago
parent
commit
49d587cd42
  1. 18
      lib/Cargo.lock
  2. 2
      lib/Cargo.toml
  3. 1
      src/controller.cpp
  4. 1
      src/mainwindow.h
  5. 55
      src/mainwindow.ui
  6. 47
      src/sendtab.cpp

18
lib/Cargo.lock

@ -172,7 +172,7 @@ checksum = "cdcf67bb7ba7797a081cd19009948ab533af7c355d5caf1d08c777582d351e9c"
[[package]]
name = "bellman"
version = "0.1.0"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"bit-vec",
"blake2s_simd",
@ -497,7 +497,7 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "ff"
version = "0.4.0"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"byteorder",
"ff_derive",
@ -507,7 +507,7 @@ dependencies = [
[[package]]
name = "ff_derive"
version = "0.3.0"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"num-bigint",
"num-integer",
@ -665,7 +665,7 @@ dependencies = [
[[package]]
name = "group"
version = "0.1.0"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"ff",
"rand 0.7.3",
@ -1132,7 +1132,7 @@ dependencies = [
[[package]]
name = "pairing"
version = "0.14.2"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"byteorder",
"ff",
@ -1849,7 +1849,7 @@ dependencies = [
[[package]]
name = "silentdragonlitelib"
version = "0.1.0"
source = "git+https://git.hush.is/hush/silentdragonlite-cli?rev=1334c89e0f4ddd23725020e16753d0ea95c09bf5#1334c89e0f4ddd23725020e16753d0ea95c09bf5"
source = "git+https://git.hush.is/hush/silentdragonlite-cli?rev=8fc0dc539a3b29655f0538c671b42feee5205641#8fc0dc539a3b29655f0538c671b42feee5205641"
dependencies = [
"base58",
"bellman",
@ -2695,7 +2695,7 @@ dependencies = [
[[package]]
name = "zcash_client_backend"
version = "0.0.0"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"bech32",
"bs58",
@ -2711,7 +2711,7 @@ dependencies = [
[[package]]
name = "zcash_primitives"
version = "0.0.0"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"aes",
"blake2b_simd",
@ -2734,7 +2734,7 @@ dependencies = [
[[package]]
name = "zcash_proofs"
version = "0.0.0"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37#1a0204113d487cdaaf183c2967010e5214ff9e37"
source = "git+https://git.hush.is/hush/librustzcash.git?rev=acff1444ec373e9c3e37b47ca95bfd358e45255b#acff1444ec373e9c3e37b47ca95bfd358e45255b"
dependencies = [
"bellman",
"blake2b_simd",

2
lib/Cargo.toml

@ -12,4 +12,4 @@ crate-type = ["staticlib"]
libc = "0.2.58"
lazy_static = "1.4.0"
blake3 = "0.3.4"
silentdragonlitelib = { git = "https://git.hush.is/hush/silentdragonlite-cli", rev = "1334c89e0f4ddd23725020e16753d0ea95c09bf5" }
silentdragonlitelib = { git = "https://git.hush.is/hush/silentdragonlite-cli", rev = "8fc0dc539a3b29655f0538c671b42feee5205641" }

1
src/controller.cpp

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

1
src/mainwindow.h

@ -161,6 +161,7 @@ private:
void addAddressSection();
void maxAmountChecked(int checked);
void toggleMinerFeeEditable(int state);
void editSchedule();

55
src/mainwindow.ui

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

47
src/sendtab.cpp

@ -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());
}
}
Loading…
Cancel
Save