electrum

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

commit 915e132c335f8a4c70538088d7c6ce602de0f054
parent 9e1c4a59e56f0463281bb36fc7fe39482640fe26
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 27 Nov 2020 12:48:32 +0100

fix 'max' button in Kivy (fix #6169)

Diffstat:
Melectrum/gui/kivy/main_window.py | 7++++++-
Melectrum/gui/kivy/uix/dialogs/amount_dialog.py | 5++++-
Melectrum/gui/kivy/uix/dialogs/lightning_open_channel.py | 3++-
Melectrum/gui/kivy/uix/screens.py | 16+++++++++++-----
4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py @@ -1173,7 +1173,12 @@ class ElectrumWindow(App, Logger): amount, u = str(amount).split() assert u == self.base_unit def cb(amount): - screen.amount = amount + if amount == '!': + screen.is_max = True + screen.amount = self.get_max_amount() + ' ' + self.base_unit + else: + screen.amount = amount + screen.is_max = False popup = AmountDialog(show_max, amount, cb) popup.open() diff --git a/electrum/gui/kivy/uix/dialogs/amount_dialog.py b/electrum/gui/kivy/uix/dialogs/amount_dialog.py @@ -49,6 +49,7 @@ Builder.load_string(''' amount: '' fiat_amount: '' is_fiat: False + is_max: False on_fiat_amount: if self.is_fiat: self.amount = app.fiat_to_btc(self.fiat_amount) on_amount: if not self.is_fiat: self.fiat_amount = app.btc_to_fiat(self.amount) size_hint: 1, None @@ -92,6 +93,7 @@ Builder.load_string(''' on_release: kb.is_fiat = False kb.amount = app.get_max_amount() + kb.is_max = True Button: size_hint: 1, None height: '48dp' @@ -99,6 +101,7 @@ Builder.load_string(''' on_release: kb.amount = '' kb.fiat_amount = '' + kb.is_max = False Widget: size_hint: 1, 0.2 BoxLayout: @@ -112,7 +115,7 @@ Builder.load_string(''' height: '48dp' text: _('OK') on_release: - root.callback(btc.text if kb.amount else '') + root.callback('!' if kb.is_max else btc.text if kb.amount else '') popup.dismiss() ''') diff --git a/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py b/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py @@ -23,6 +23,7 @@ Builder.load_string(''' title: _('Open Lightning Channel') pubkey: '' amount: '' + is_max: False ipport: '' BoxLayout spacing: '12dp' @@ -154,7 +155,7 @@ class LightningOpenChannelDialog(Factory.Popup, Logger): conn_str = self.pubkey if self.ipport: conn_str += '@' + self.ipport.strip() - amount = self.app.get_amount(self.amount) + amount = '!' if self.is_max else self.app.get_amount(self.amount) self.app.protected('Create a new channel?', self.do_open_channel, (conn_str, amount)) self.dismiss() diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py @@ -196,6 +196,7 @@ class SendScreen(CScreen, Logger): self.address = uri.get('address', '') self.message = uri.get('message', '') self.amount = self.app.format_amount_and_units(amount) if amount else '' + self.is_max = False self.payment_request = None self.is_lightning = False @@ -260,6 +261,7 @@ class SendScreen(CScreen, Logger): self.is_lightning = False self.is_bip70 = False self.parsed_URI = None + self.is_max = False def set_request(self, pr: 'PaymentRequest'): self.address = pr.get_requestor() @@ -298,11 +300,14 @@ class SendScreen(CScreen, Logger): if not self.amount: self.app.show_error(_('Please enter an amount')) return - try: - amount = self.app.get_amount(self.amount) - except: - self.app.show_error(_('Invalid amount') + ':\n' + self.amount) - return + if self.is_max: + amount = '!' + else: + try: + amount = self.app.get_amount(self.amount) + except: + self.app.show_error(_('Invalid amount') + ':\n' + self.amount) + return message = self.message if self.is_lightning: return LNInvoice.from_bech32(address) @@ -439,6 +444,7 @@ class ReceiveScreen(CScreen): def clear(self): self.address = '' self.amount = '' + self.is_max = False # not used for receiving (see app.amount_dialog) self.message = '' self.lnaddr = ''