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

47
src/sendtab.cpp

@ -495,30 +495,34 @@ void MainWindow::maxAmountChecked(int checked) {
Tx MainWindow::createTxFromSendPage() { Tx MainWindow::createTxFromSendPage() {
Tx tx; Tx tx;
bool sendChangeToSapling = Settings::getInstance()->getAutoShield();
// Gather the from / to addresses // Gather the from / to addresses
tx.fromAddr = ui->inputsCombo->currentText(); tx.fromAddr = ui->inputsCombo->currentText();
sendChangeToSapling = sendChangeToSapling && Settings::isTAddress(tx.fromAddr);
// For each addr/amt in the sendTo tab // For each addr/amt in the sendTo tab
int totalItems = ui->sendToWidgets->children().size() - 2; // The last one is a spacer, so ignore that 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++) { for (int i=0; i < totalItems; i++) {
QString addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") % QString::number(i+1))->text().trimmed(); QString addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") % QString::number(i+1))->text().trimmed();
// Remove label if it exists // Remove label if it exists
addr = AddressBook::addressFromAddressLabel(addr); 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(); QString amtStr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed();
if (amtStr.isEmpty()) { if (amtStr.isEmpty()) {
amtStr = "-1";; // The user didn't specify an amount amtStr = "-1";; // The user didn't specify an amount
} }
double amt = amtStr.toDouble(); bool ok;
totalAmt += amt; 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(); QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
tx.toAddrs.push_back( ToFields{addr, amt, memo} ); tx.toAddrs.push_back( ToFields{addr, amt, memo} );
@ -529,31 +533,6 @@ Tx MainWindow::createTxFromSendPage() {
} else { } else {
tx.fee = Settings::getMinerFee(); 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; return tx;
} }

153
src/settings.ui

@ -145,30 +145,16 @@
<string>Options</string> <string>Options</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="10" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_5">
<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">
<property name="text"> <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>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </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"> <item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="chkSaveTxs"> <widget class="QCheckBox" name="chkSaveTxs">
<property name="text"> <property name="text">
@ -176,84 +162,68 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="0" colspan="2"> <item row="3" column="0">
<widget class="QLabel" name="label_10"> <widget class="QCheckBox" name="chkCustomFees">
<property name="text"> <property name="text">
<string>Connect to the internet to fetch ZEC prices</string> <string>Allow custom fees</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="8" column="0" colspan="2">
<spacer name="horizontalSpacer"> <widget class="QLabel" name="label_8">
<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">
<property name="text"> <property name="text">
<string>Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. </string> <string>Connect to github on startup to check for updates</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="chkCheckUpdates"> <widget class="QCheckBox" name="chkFetchPrices">
<property name="text"> <property name="text">
<string>Check github for updates at startup</string> <string>Fetch ZEC / USD prices</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_10">
<property name="text"> <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> <string>Connect to the internet to fetch ZEC prices</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="chkAutoShield"> <widget class="QLabel" name="lblTor">
<property name="text"> <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> </property>
</widget> </widget>
</item> </item>
<item row="16" column="0" colspan="2"> <item row="13" column="0">
<widget class="Line" name="line_2"> <widget class="QLabel" name="label_20">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Theme</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2"> <item row="2" column="1">
<widget class="QLabel" name="lblTor"> <widget class="QPushButton" name="btnClearSaved">
<property name="text"> <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> <string>Clear History</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="17" column="0" colspan="2"> <item row="15" column="0" colspan="2">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -266,44 +236,44 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="7" column="0"> <item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="chkTor"> <widget class="QLabel" name="label_6">
<property name="text"> <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> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="chkCustomFees"> <widget class="QCheckBox" name="chkCheckUpdates">
<property name="text"> <property name="text">
<string>Allow custom fees</string> <string>Check github for updates at startup</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0" colspan="2"> <item row="5" column="0">
<widget class="QCheckBox" name="chkFetchPrices"> <widget class="QCheckBox" name="chkTor">
<property name="text"> <property name="text">
<string>Fetch ZEC / USD prices</string> <string>Connect via Tor</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="15" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_20"> <spacer name="horizontalSpacer">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Theme</string>
</property> </property>
<property name="alignment"> <property name="sizeHint" stdset="0">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
<item row="15" column="1"> <item row="13" column="1">
<widget class="QComboBox" name="comboBoxTheme"> <widget class="QComboBox" name="comboBoxTheme">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -333,6 +303,19 @@
</item> </item>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">

Loading…
Cancel
Save