Browse Source

kivy: do not save invoice until payment is confirmed by user.

add confirmation screen for lightning payments.
master
ThomasV 5 years ago
parent
commit
2f13e4eb85
  1. 16
      electrum/gui/kivy/uix/screens.py

16
electrum/gui/kivy/uix/screens.py

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

Loading…
Cancel
Save