diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 96da319a5..f1657738f 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -1264,14 +1264,28 @@ class ElectrumWindow(QMainWindow): msg += '\n\nOutputs:\n' + '\n'.join(map(lambda x: x[0] + ' ' + self.format_amount(x[1])+ self.base_unit(), pr.get_outputs())) QMessageBox.information(self, 'Invoice', msg , 'OK') + def do_pay_invoice(self, key): + from electrum.paymentrequest import PaymentRequest + domain, memo, value, status, tx_hash = self.invoices[key] + pr = PaymentRequest(self.config) + pr.read_file(key) + pr.domain = domain + pr.verify() + self.gui_object.payment_request = pr + self.prepare_for_payment_request() + self.payment_request_ok() + def create_invoice_menu(self, position): item = self.invoices_list.itemAt(position) if not item: return k = self.invoices_list.indexOfTopLevelItem(item) key = self.invoices.keys()[k] + domain, memo, value, status, tx_hash = self.invoices[key] menu = QMenu() menu.addAction(_("Details"), lambda: self.show_invoice(key)) + if status == PR_UNPAID: + menu.addAction(_("Pay Now"), lambda: self.do_pay_invoice(key)) menu.addAction(_("Delete"), lambda: self.delete_invoice(key)) menu.exec_(self.invoices_list.viewport().mapToGlobal(position)) diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py index 0dae7f633..e00de7dd5 100644 --- a/lib/paymentrequest.py +++ b/lib/paymentrequest.py @@ -141,6 +141,8 @@ class PaymentRequest: with open(filename,'r') as f: r = f.read() + assert key == bitcoin.sha256(r)[0:16].encode('hex') + self.id = key self.parse(r)