electrum

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

commit 2f13e4eb8583266310719d2ea025b4020ec54e34
parent f020125e74bcbea0e540a636bf697b9c3e6d98bc
Author: ThomasV <thomasv@electrum.org>
Date:   Sat,  5 Dec 2020 19:44:26 +0100

kivy: do not save invoice until payment is confirmed by user.
add confirmation screen for lightning payments.

Diffstat:
Melectrum/gui/kivy/uix/screens.py | 16+++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py @@ -329,6 +329,9 @@ class SendScreen(CScreen, Logger): invoice = self.read_invoice() if not invoice: return + self.save_invoice(invoice) + + def save_invoice(self, invoice): self.app.wallet.save_invoice(invoice) self.do_clear() self.update() @@ -337,14 +340,11 @@ class SendScreen(CScreen, Logger): invoice = self.read_invoice() if not invoice: return - self.app.wallet.save_invoice(invoice) - self.do_clear() - self.update() self.do_pay_invoice(invoice) def do_pay_invoice(self, invoice): if invoice.is_lightning(): - self._do_pay_lightning(invoice) + self.app.protected(_('Pay lightning invoice?'), self._do_pay_lightning, (invoice,)) return else: do_pay = lambda rbf: self._do_pay_onchain(invoice, rbf) @@ -354,7 +354,8 @@ class SendScreen(CScreen, Logger): else: do_pay(False) - def _do_pay_lightning(self, invoice: LNInvoice) -> None: + def _do_pay_lightning(self, invoice: LNInvoice, pw) -> None: + self.save_invoice(invoice) threading.Thread( target=self.app.wallet.lnworker.pay, args=(invoice.invoice,), @@ -397,11 +398,12 @@ class SendScreen(CScreen, Logger): elif feerate > FEERATE_WARNING_HIGH_FEE / 1000: msg.append(_('Warning') + ': ' + _("The fee for this transaction seems unusually high.") + f' (feerate: {feerate:.2f} sat/byte)') - self.app.protected('\n'.join(msg), self.send_tx, (tx,)) + self.app.protected('\n'.join(msg), self.send_tx, (tx, invoice)) - def send_tx(self, tx, password): + def send_tx(self, tx, invoice, password): if self.app.wallet.has_password() and password is None: return + self.save_invoice(invoice) def on_success(tx): if tx.is_complete(): self.app.broadcast(tx)