From a8ecc68833b6a64bac614a61736f621dc55aeb7b Mon Sep 17 00:00:00 2001 From: Siddhant Chawla Date: Thu, 22 Jul 2021 23:53:32 +0530 Subject: [PATCH] Added BTC and Fiat amount on the confirmation screen for Lightning Invoice (#7425) Added BTC and Fiat amount(as enabled by the user) on the confirmation screen for a Lightning Invoice in the Kivy GUI closes https://github.com/spesmilo/electrum/issues/7410 --- electrum/gui/kivy/main_window.py | 7 +++++++ electrum/gui/kivy/uix/screens.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py index e078603fc..78c5e0e47 100644 --- a/electrum/gui/kivy/main_window.py +++ b/electrum/gui/kivy/main_window.py @@ -973,6 +973,13 @@ class ElectrumWindow(App, Logger): # via self.get_amount()... the need for converting back should be removed return format_satoshis_plain(x, decimal_point=self.decimal_point()) + ' ' + self.base_unit + def format_amount_and_units_with_fiat(self, x) -> str: + text = self.format_amount_and_units(x) + fiat = self.fx.format_amount_and_units(x) if self.fx else None + if text and fiat: + text += f' ({fiat})' + return text + def format_fee_rate(self, fee_rate): # fee_rate is in sat/kB return format_fee_satoshis(fee_rate/1000) + ' sat/byte' diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py index 53c19a57d..091dcd0c2 100644 --- a/electrum/gui/kivy/uix/screens.py +++ b/electrum/gui/kivy/uix/screens.py @@ -341,7 +341,9 @@ class SendScreen(CScreen, Logger): def do_pay_invoice(self, invoice): if invoice.is_lightning(): if self.app.wallet.lnworker: - self.app.protected(_('Pay lightning invoice?'), self._do_pay_lightning, (invoice,)) + amount_sat = invoice.get_amount_sat() + msg = _("Pay lightning invoice?") + '\n\n' + _("This will send {}?").format(self.app.format_amount_and_units_with_fiat(amount_sat)) +'\n' + self.app.protected(msg, self._do_pay_lightning, (invoice,)) else: self.app.show_error(_("Lightning payments are not available for this wallet")) else: