commit 503fd99cdb1256341ad6f2c1f504b2d6851035bd
parent 4e1068b34307786642045dfa1122d8429d73202d
Author: ThomasV <thomasv@gitorious>
Date: Thu, 12 Jun 2014 15:35:46 +0200
add pay_invoice menu item
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git 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
@@ -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)