1
0

kivy: fix some bugs when paying 'max'

fixes: #6164
This commit is contained in:
SomberNight
2020-05-15 19:12:15 +02:00
parent eba3fa03ee
commit 937c0f36ae
3 changed files with 8 additions and 4 deletions

View File

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

View File

@@ -17,7 +17,7 @@ if TYPE_CHECKING:
Builder.load_string('''
<InvoiceDialog@Popup>
id: popup
amount: 0
amount: None
title: ''
data: ''
description:''

View File

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