electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 937c0f36ae1e47fdd054eb6b2ea931d3c5d68eec
parent eba3fa03ee2ac70a6cf2516bf5b9aa6452547304
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:
Melectrum/gui/kivy/main_window.py | 8++++++--
Melectrum/gui/kivy/uix/dialogs/invoice_dialog.py | 2+-
Melectrum/gui/kivy/uix/screens.py | 2+-
3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py @@ -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, '!')] @@ -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): diff --git a/electrum/gui/kivy/uix/dialogs/invoice_dialog.py b/electrum/gui/kivy/uix/dialogs/invoice_dialog.py @@ -17,7 +17,7 @@ if TYPE_CHECKING: Builder.load_string(''' <InvoiceDialog@Popup> id: popup - amount: 0 + amount: None title: '' data: '' description:'' diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py @@ -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) @@ -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),