Browse Source

Remove autoshield setting

pull/14/head
Aditya Kulkarni 5 years ago
parent
commit
36ece2ace0
  1. 6
      src/mainwindow.cpp
  2. 47
      src/sendtab.cpp
  3. 153
      src/settings.ui

6
src/mainwindow.cpp

@ -278,9 +278,6 @@ void MainWindow::setupSettingsModal() {
// Custom fees
settings.chkCustomFees->setChecked(Settings::getInstance()->getAllowCustomFees());
// Auto shielding
settings.chkAutoShield->setChecked(Settings::getInstance()->getAutoShield());
// Check for updates
settings.chkCheckUpdates->setChecked(Settings::getInstance()->getCheckForUpdates());
@ -342,9 +339,6 @@ void MainWindow::setupSettingsModal() {
if (!customFees)
ui->minerFeeAmt->setText(Settings::getDecimalString(Settings::getMinerFee()));
// Auto shield
Settings::getInstance()->setAutoShield(settings.chkAutoShield->isChecked());
// Check for updates
Settings::getInstance()->setCheckForUpdates(settings.chkCheckUpdates->isChecked());

47
src/sendtab.cpp

@ -495,30 +495,34 @@ void MainWindow::maxAmountChecked(int checked) {
Tx MainWindow::createTxFromSendPage() {
Tx tx;
bool sendChangeToSapling = Settings::getInstance()->getAutoShield();
// Gather the from / to addresses
tx.fromAddr = ui->inputsCombo->currentText();
sendChangeToSapling = sendChangeToSapling && Settings::isTAddress(tx.fromAddr);
// For each addr/amt in the sendTo tab
int totalItems = ui->sendToWidgets->children().size() - 2; // The last one is a spacer, so ignore that
double totalAmt = 0;
qint64 totalAmt = 0;
for (int i=0; i < totalItems; i++) {
QString addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") % QString::number(i+1))->text().trimmed();
// Remove label if it exists
addr = AddressBook::addressFromAddressLabel(addr);
// If address is sprout, then we can't send change to sapling, because of turnstile.
sendChangeToSapling = sendChangeToSapling && !Settings::getInstance()->isSproutAddress(addr);
QString amtStr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed();
if (amtStr.isEmpty()) {
amtStr = "-1";; // The user didn't specify an amount
}
double amt = amtStr.toDouble();
totalAmt += amt;
bool ok;
qint64 amt;
// Make sure it parses
amtStr.toDouble(&ok);
if (!ok) {
amt = -1;
} else {
amt = Settings::getAmountFromUserDecimalStr(amtStr);
totalAmt += amt;
}
QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
tx.toAddrs.push_back( ToFields{addr, amt, memo} );
@ -529,31 +533,6 @@ Tx MainWindow::createTxFromSendPage() {
} else {
tx.fee = Settings::getMinerFee();
}
if (Settings::getInstance()->getAutoShield() && sendChangeToSapling) {
auto saplingAddr = std::find_if(rpc->getModel()->getAllZAddresses().begin(), rpc->getModel()->getAllZAddresses().end(), [=](auto i) -> bool {
// We're finding a sapling address that is not one of the To addresses, because zcash doesn't allow duplicated addresses
bool isSapling = Settings::getInstance()->isSaplingAddress(i);
if (!isSapling) return false;
// Also check all the To addresses
for (auto t : tx.toAddrs) {
if (t.addr == i)
return false;
}
return true;
});
if (saplingAddr != rpc->getModel()->getAllZAddresses().end()) {
double change = rpc->getModel()->getAllBalances().value(tx.fromAddr) - totalAmt - tx.fee;
if (Settings::getDecimalString(change) != "0") {
QString changeMemo = tr("Change from ") + tx.fromAddr;
tx.toAddrs.push_back(ToFields{ *saplingAddr, change, changeMemo });
}
}
}
return tx;
}

153
src/settings.ui

@ -145,30 +145,16 @@
<string>Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Connect to github on startup to check for updates</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Normally, change from t-Addresses goes to another t-Address. Checking this option will send the change to your shielded sapling address instead. Check this option to increase your privacy.</string>
<string>Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="btnClearSaved">
<property name="text">
<string>Clear History</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="chkSaveTxs">
<property name="text">
@ -176,84 +162,68 @@
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="QLabel" name="label_10">
<item row="3" column="0">
<widget class="QCheckBox" name="chkCustomFees">
<property name="text">
<string>Connect to the internet to fetch ZEC prices</string>
<string>Allow custom fees</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. </string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Connect to github on startup to check for updates</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="chkCheckUpdates">
<widget class="QCheckBox" name="chkFetchPrices">
<property name="text">
<string>Check github for updates at startup</string>
<string>Fetch ZEC / USD prices</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Connect to the internet to fetch ZEC prices</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="chkAutoShield">
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="lblTor">
<property name="text">
<string>Shield change from t-Addresses to your sapling address</string>
<string>Connect to the Tor network via SOCKS proxy running on 127.0.0.1:9050. Please note that you'll have to install and run the Tor service externally.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="16" column="0" colspan="2">
<widget class="Line" name="line_2">
<item row="13" column="0">
<widget class="QLabel" name="label_20">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="text">
<string>Theme</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="lblTor">
<item row="2" column="1">
<widget class="QPushButton" name="btnClearSaved">
<property name="text">
<string>Connect to the Tor network via SOCKS proxy running on 127.0.0.1:9050. Please note that you'll have to install and run the Tor service externally.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Clear History</string>
</property>
</widget>
</item>
<item row="17" column="0" colspan="2">
<item row="15" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -266,44 +236,44 @@
</property>
</spacer>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="chkTor">
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Connect via Tor</string>
<string>Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. </string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkCustomFees">
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="chkCheckUpdates">
<property name="text">
<string>Allow custom fees</string>
<string>Check github for updates at startup</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="chkFetchPrices">
<item row="5" column="0">
<widget class="QCheckBox" name="chkTor">
<property name="text">
<string>Fetch ZEC / USD prices</string>
<string>Connect via Tor</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_20">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Theme</string>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="15" column="1">
<item row="13" column="1">
<widget class="QComboBox" name="comboBoxTheme">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -333,6 +303,19 @@
</item>
</widget>
</item>
<item row="14" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">

Loading…
Cancel
Save