commit 1d0aa4042a74136e85929edbfe683432ef00591d
parent 787ac5fe994086b994524201fec4b63f876c7c85
Author: SomberNight <somber.night@protonmail.com>
Date: Tue, 31 Dec 2019 03:08:47 +0100
fix paying bip70 payment request with Qt GUI
Diffstat:
2 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py
@@ -621,7 +621,7 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
height = self.wallet.get_tx_height(tx_hash).height
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
is_unconfirmed = height <= 0
- #pr_key = self.wallet.invoices.paid.get(tx_hash)
+ invoice_keys = self.wallet._get_relevant_invoice_keys_for_tx(tx)
menu = QMenu()
if height in [TX_HEIGHT_FUTURE, TX_HEIGHT_LOCAL]:
menu.addAction(_("Remove"), lambda: self.remove_local_tx(tx_hash))
@@ -643,8 +643,8 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
child_tx = self.wallet.cpfp(tx, 0)
if child_tx:
menu.addAction(_("Child pays for parent"), lambda: self.parent.cpfp(tx, child_tx))
- #if pr_key:
- # menu.addAction(read_QIcon("seal"), _("View invoice"), lambda: self.parent.show_invoice(pr_key))
+ if invoice_keys:
+ menu.addAction(read_QIcon("seal"), _("View invoice"), lambda: [self.parent.show_invoice(key) for key in invoice_keys])
if tx_URL:
menu.addAction(_("View on block explorer"), lambda: webopen(tx_URL))
menu.exec_(self.viewport().mapToGlobal(position))
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
@@ -1745,7 +1745,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
self.payment_request = None
self.do_clear()
- def on_pr(self, request):
+ def on_pr(self, request: 'paymentrequest.PaymentRequest'):
+ self.set_onchain(True)
self.payment_request = request
if self.payment_request.verify(self.contacts):
self.payment_request_ok_signal.emit()
@@ -1922,7 +1923,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
pr.verify(self.contacts)
self.show_bip70_details(pr)
- def show_bip70_details(self, pr):
+ def show_bip70_details(self, pr: 'paymentrequest.PaymentRequest'):
key = pr.get_id()
d = WindowModalDialog(self, _("BIP70 Invoice"))
vbox = QVBoxLayout(d)
@@ -1930,7 +1931,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
grid.addWidget(QLabel(_("Requestor") + ':'), 0, 0)
grid.addWidget(QLabel(pr.get_requestor()), 0, 1)
grid.addWidget(QLabel(_("Amount") + ':'), 1, 0)
- outputs_str = '\n'.join(map(lambda x: self.format_amount(x[2])+ self.base_unit() + ' @ ' + x[1], pr.get_outputs()))
+ outputs_str = '\n'.join(map(lambda x: self.format_amount(x.value)+ self.base_unit() + ' @ ' + x.address, pr.get_outputs()))
grid.addWidget(QLabel(outputs_str), 1, 1)
expires = pr.get_expiration_date()
grid.addWidget(QLabel(_("Memo") + ':'), 2, 0)
@@ -1950,26 +1951,17 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
data = f.write(pr.raw)
self.show_message(_('Invoice saved as' + ' ' + fn))
exportButton = EnterButton(_('Save'), do_export)
- def do_delete():
- if self.question(_('Delete invoice?')):
- self.wallet.delete_invoices(key)
- self.history_list.update()
- self.invoice_list.update()
- d.close()
- deleteButton = EnterButton(_('Delete'), do_delete)
- vbox.addLayout(Buttons(exportButton, deleteButton, CloseButton(d)))
+ # note: "delete" disabled as invoice is saved with a different key in wallet.invoices that we do not have here
+ # def do_delete():
+ # if self.question(_('Delete invoice?')):
+ # self.wallet.delete_invoice(key)
+ # self.history_list.update()
+ # self.invoice_list.update()
+ # d.close()
+ # deleteButton = EnterButton(_('Delete'), do_delete)
+ vbox.addLayout(Buttons(exportButton, CloseButton(d)))
d.exec_()
- def pay_bip70_invoice(self, key):
- pr = self.wallet.get_invoice(key)
- self.payment_request = pr
- self.prepare_for_payment_request()
- pr.error = None # this forces verify() to re-run
- if pr.verify(self.contacts):
- self.payment_request_ok()
- else:
- self.payment_request_error()
-
def create_console_tab(self):
from .console import Console
self.console = console = Console()