Browse Source

qt payment requests: fix some races

closes #5283, #5407, #5121
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 6 years ago
parent
commit
d2de8de356
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 19
      electrum/gui/qt/main_window.py
  2. 2
      electrum/paymentrequest.py

19
electrum/gui/qt/main_window.py

@ -1602,11 +1602,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
"""Returns whether there are errors with outputs.
Also shows error dialog to user if so.
"""
if self.payment_request and self.payment_request.has_expired():
self.show_error(_('Payment request has expired'))
return True
pr = self.payment_request
if pr:
if pr.error:
return True
if pr.has_expired():
self.show_error(_('Payment request has expired'))
return True
if not self.payment_request:
if not pr:
errors = self.payto_e.get_errors()
if errors:
self.show_warning(_("Invalid Lines found:") + "\n\n" + '\n'.join([ _("Line #") + str(x[0]+1) + ": " + x[1] for x in errors]))
@ -1820,6 +1824,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
def payment_request_ok(self):
pr = self.payment_request
if not pr:
return
key = self.invoices.add(pr)
status = self.invoices.get_status(key)
self.invoice_list.update()
@ -1840,7 +1846,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
self.amount_e.textEdited.emit("")
def payment_request_error(self):
self.show_message(self.payment_request.error)
pr = self.payment_request
if not pr:
return
self.show_message(pr.error)
self.payment_request = None
self.do_clear()

2
electrum/paymentrequest.py

@ -123,6 +123,7 @@ class PaymentRequest:
return str(self.raw)
def parse(self, r):
self.outputs = []
if self.error:
return
self.id = bh2u(sha256(r)[0:16])
@ -134,7 +135,6 @@ class PaymentRequest:
return
self.details = pb2.PaymentDetails()
self.details.ParseFromString(self.data.serialized_payment_details)
self.outputs = []
for o in self.details.outputs:
type_, addr = transaction.get_address_from_output_script(o.script)
if type_ != TYPE_ADDRESS:

Loading…
Cancel
Save