electrum

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

commit d2de8de356213585eccb5d4b963429f9a674ed65
parent 0ec574bcf8b9d58462efee700df96a744a753435
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  5 Jun 2019 16:29:33 +0200

qt payment requests: fix some races

closes #5283, #5407, #5121

Diffstat:
Melectrum/gui/qt/main_window.py | 19++++++++++++++-----
Melectrum/paymentrequest.py | 2+-
2 files changed, 15 insertions(+), 6 deletions(-)

diff --git 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 @@ -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: