diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 87e3dc266..7c252afb1 100644 --- a/electrum/gui/qt/main_window.py +++ b/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() diff --git a/electrum/paymentrequest.py b/electrum/paymentrequest.py index 881a3eea2..05967918d 100644 --- a/electrum/paymentrequest.py +++ b/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: