tkivy: fix some bugs when paying 'max' - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 937c0f36ae1e47fdd054eb6b2ea931d3c5d68eec DIR parent eba3fa03ee2ac70a6cf2516bf5b9aa6452547304 HTML Author: SomberNight <somber.night@protonmail.com> Date: Fri, 15 May 2020 19:12:15 +0200 kivy: fix some bugs when paying 'max' fixes: #6164 Diffstat: M electrum/gui/kivy/main_window.py | 8 ++++++-- M electrum/gui/kivy/uix/dialogs/invo… | 2 +- M electrum/gui/kivy/uix/screens.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) --- DIR diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py t@@ -916,7 +916,7 @@ class ElectrumWindow(App): return '' addr = None if self.send_screen: - addr = str(self.send_screen.screen.address) + addr = str(self.send_screen.address) if not addr: addr = self.wallet.dummy_address() outputs = [PartialTxOutput.from_address_and_value(addr, '!')] t@@ -939,7 +939,11 @@ class ElectrumWindow(App): def format_amount(self, x, is_diff=False, whitespaces=False): return format_satoshis(x, 0, self.decimal_point(), is_diff=is_diff, whitespaces=whitespaces) - def format_amount_and_units(self, x): + def format_amount_and_units(self, x) -> str: + if x is None: + return 'none' + if x == '!': + return 'max' return format_satoshis_plain(x, self.decimal_point()) + ' ' + self.base_unit def format_fee_rate(self, fee_rate): DIR diff --git a/electrum/gui/kivy/uix/dialogs/invoice_dialog.py b/electrum/gui/kivy/uix/dialogs/invoice_dialog.py t@@ -17,7 +17,7 @@ if TYPE_CHECKING: Builder.load_string(''' <InvoiceDialog@Popup> id: popup - amount: 0 + amount: None title: '' data: '' description:'' DIR diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py t@@ -348,7 +348,6 @@ class SendScreen(CScreen): def _do_pay_onchain(self, invoice, rbf): # make unsigned transaction outputs = invoice['outputs'] # type: List[PartialTxOutput] - amount = sum(map(lambda x: x.value, outputs)) coins = self.app.wallet.get_spendable_coins(None) try: tx = self.app.wallet.make_unsigned_transaction(coins=coins, outputs=outputs) t@@ -362,6 +361,7 @@ class SendScreen(CScreen): if rbf: tx.set_rbf(True) fee = tx.get_fee() + amount = sum(map(lambda x: x.value, outputs)) if '!' not in [x.value for x in outputs] else tx.output_value() msg = [ _("Amount to be sent") + ": " + self.app.format_amount_and_units(amount), _("Mining fee") + ": " + self.app.format_amount_and_units(fee),