commit 1b36dd76901b5ff81a626fd25529f6a65edddb0b
parent cf809520718ac53d94dec06dea6a44eefd425390
Author: SomberNight <somber.night@protonmail.com>
Date: Fri, 8 Jun 2018 18:45:20 +0200
fix "max" button to account for 2fa fees in both Qt and kivy
Diffstat:
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
@@ -694,6 +694,8 @@ class ElectrumWindow(App):
self.fiat_balance = self.fx.format_amount(c+u+x) + ' [size=22dp]%s[/size]'% self.fx.ccy
def get_max_amount(self):
+ if run_hook('abort_send', self):
+ return ''
inputs = self.wallet.get_spendable_coins(None, self.electrum_config)
if not inputs:
return ''
@@ -705,7 +707,9 @@ class ElectrumWindow(App):
Clock.schedule_once(lambda dt, bound_e=e: self.show_error(str(bound_e)))
return ''
amount = tx.output_value()
- return format_satoshis_plain(amount, self.decimal_point())
+ __, x_fee_amount = run_hook('get_tx_extra_fee', self.wallet, tx) or (None, 0)
+ amount_after_all_fees = amount - x_fee_amount
+ return format_satoshis_plain(amount_after_all_fees, self.decimal_point())
def format_amount(self, x, is_diff=False, whitespaces=False):
return format_satoshis(x, 0, self.decimal_point(), is_diff=is_diff, whitespaces=whitespaces)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -1267,6 +1267,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return w
def spend_max(self):
+ if run_hook('abort_send', self):
+ return
self.is_max = True
self.do_update_fee()
@@ -1364,7 +1366,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if self.is_max:
amount = tx.output_value()
- self.amount_e.setAmount(amount)
+ __, x_fee_amount = run_hook('get_tx_extra_fee', self.wallet, tx) or (None, 0)
+ amount_after_all_fees = amount - x_fee_amount
+ self.amount_e.setAmount(amount_after_all_fees)
def from_list_delete(self, item):
i = self.from_list.indexOfTopLevelItem(item)
diff --git a/plugins/trustedcoin/kivy.py b/plugins/trustedcoin/kivy.py
@@ -93,3 +93,18 @@ class Plugin(TrustedCoinPlugin):
def request_otp_dialog(self, wizard, short_id, otp_secret, xpub3):
f = lambda otp, reset: self.check_otp(wizard, short_id, otp_secret, xpub3, otp, reset)
wizard.otp_dialog(otp_secret=otp_secret, run_next=f)
+
+ @hook
+ def abort_send(self, window):
+ wallet = window.wallet
+ if not isinstance(wallet, self.wallet_class):
+ return
+ if wallet.can_sign_without_server():
+ return
+ if wallet.billing_info is None:
+ self.start_request_thread(wallet)
+ Clock.schedule_once(
+ lambda dt: window.show_error(_('Requesting account info from TrustedCoin server...') + '\n' +
+ _('Please try again.')))
+ return True
+ return False