Browse Source

kivy: fix some bugs when paying 'max'

fixes: #6164
master
SomberNight 5 years ago
parent
commit
937c0f36ae
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 8
      electrum/gui/kivy/main_window.py
  2. 2
      electrum/gui/kivy/uix/dialogs/invoice_dialog.py
  3. 2
      electrum/gui/kivy/uix/screens.py

8
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):

2
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:''

2
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),

Loading…
Cancel
Save