diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index a3e79be18..201f80d06 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -1189,12 +1189,12 @@ class ElectrumWindow(QMainWindow): def payment_request_ok(self): pr = self.payment_request - status = pr.get_status() key = self.invoices.add(pr) + status = self.invoices.get_status(key) self.update_invoices_list() if status == PR_PAID: - self.do_clear() self.show_message("invoice already paid") + self.do_clear() self.payment_request = None return @@ -1306,7 +1306,7 @@ class ElectrumWindow(QMainWindow): l.clear() for pr in inv_list: key = pr.get_id() - status = pr.get_status() + status = self.invoices.get_status(key) domain = pr.get_domain() date_str = format_time(pr.get_expiration_date()) item = QTreeWidgetItem( [ date_str, domain, pr.memo, self.format_amount(pr.get_amount(), whitespaces=True), pr_tooltips.get(status,'')] ) @@ -1485,7 +1485,9 @@ class ElectrumWindow(QMainWindow): grid.addWidget(QLabel(outputs_str), 5, 1) if pr.tx: grid.addWidget(QLabel(_("Transaction ID") + ':'), 6, 0) - grid.addWidget(QLabel(pr.tx), 6, 1) + l = QLineEdit(pr.tx) + l.setReadOnly(True) + grid.addWidget(l, 6, 1) vbox.addLayout(grid) vbox.addLayout(Buttons(CloseButton(d))) d.exec_() @@ -1508,7 +1510,7 @@ class ElectrumWindow(QMainWindow): return key = str(item.data(0, 32).toString()) pr = self.invoices.get(key) - status = pr.get_status() + status = self.invoices.get_status(key) menu = QMenu() menu.addAction(_("Details"), lambda: self.show_invoice(key)) if status == PR_UNPAID: diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py index 3b2a5c6d5..91e2a39b1 100644 --- a/lib/paymentrequest.py +++ b/lib/paymentrequest.py @@ -84,13 +84,6 @@ class PaymentRequest: def __str__(self): return self.raw - def get_status(self): - if self.tx is not None: - return PR_PAID - if self.has_expired(): - return PR_EXPIRED - return PR_UNPAID - def parse(self, r): self.id = bitcoin.sha256(r)[0:16].encode('hex') try: @@ -330,11 +323,19 @@ class InvoiceStore(object): with open(path, 'w') as f: r = f.write(json.dumps(l)) + def get_status(self, key): + pr = self.get(key) + if pr.tx is not None: + return PR_PAID + if pr.has_expired(): + return PR_EXPIRED + return PR_UNPAID + def add(self, pr): key = pr.get_id() if key in self.invoices: print_error('invoice already in list') - return False + return key self.invoices[key] = pr self.save() return key