Browse Source

confirm_tx_dialog: fix toggle_output_rounding

master
ThomasV 3 years ago
parent
commit
37b29b1f37
  1. 19
      electrum/gui/qt/confirm_tx_dialog.py

19
electrum/gui/qt/confirm_tx_dialog.py

@ -73,6 +73,7 @@ class TxEditor(WindowModalDialog):
self.config = window.config
self.wallet = window.wallet
self.feerounding_sats = 0
self.not_enough_funds = False
self.no_dynfee_estimates = False
self.needs_update = False
@ -187,7 +188,7 @@ class TxEditor(WindowModalDialog):
self.fee_combo.setFocusPolicy(Qt.NoFocus)
def feerounding_onclick():
text = (self.feerounding_text + '\n\n' +
text = (self.feerounding_text() + '\n\n' +
_('To somewhat protect your privacy, Electrum tries to create change with similar precision to other outputs.') + ' ' +
_('At most 100 satoshis might be lost due to this rounding.') + ' ' +
_("You can disable this setting in '{}'.").format(_('Preferences')) + '\n' +
@ -268,9 +269,8 @@ class TxEditor(WindowModalDialog):
return self.feerate_e.isVisible() and self.feerate_e.isModified() \
and (self.feerate_e.text() or self.feerate_e.hasFocus())
def set_feerounding_text(self, num_satoshis_added):
self.feerounding_text = (_('Additional {} satoshis are going to be added.')
.format(num_satoshis_added))
def feerounding_text(self):
return (_('Additional {} satoshis are going to be added.').format(self.feerounding_sats))
def set_feerounding_visibility(self, b:bool):
# we do not use setVisible because it affects the layout
@ -360,8 +360,8 @@ class TxEditor(WindowModalDialog):
# set fee rounding icon to empty if there is no rounding
feerounding = (fee - displayed_fee) if (fee and displayed_fee is not None) else 0
self.set_feerounding_text(int(feerounding))
self.feerounding_icon.setToolTip(self.feerounding_text)
self.feerounding_sats = int(feerounding)
self.feerounding_icon.setToolTip(self.feerounding_text())
self.set_feerounding_visibility(abs(feerounding) >= 1)
# feerate_label needs to be updated from feerate_e
self.update_feerate_label()
@ -425,7 +425,7 @@ class TxEditor(WindowModalDialog):
_('Spend only confirmed inputs.'))
add_pref_action(
self.config.get('coin_chooser_output_rounding', True),
self.toggle_confirmed_only,
self.toggle_output_rounding,
_('Enable output value rounding'),
_('Set the value of the change output so that it has similar precision to the other outputs.') + '\n' + \
_('This might improve your privacy somewhat.') + '\n' + \
@ -447,6 +447,11 @@ class TxEditor(WindowModalDialog):
self.resize(size)
self.resize(size)
def toggle_output_rounding(self):
b = not self.config.get('coin_chooser_output_rounding', True)
self.config.set_key('coin_chooser_output_rounding', b)
self.trigger_update()
def toggle_use_change(self):
self.wallet.use_change = not self.wallet.use_change
self.wallet.db.put('use_change', self.wallet.use_change)

Loading…
Cancel
Save