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