electrum

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

commit 18bc5aa27b18d86848c455115bdffafc2b3417ea
parent 31b67c422ba118f9b09a17f1612aaa97a6a8bdf2
Author: ThomasV <thomasv@electrum.org>
Date:   Mon, 16 Jul 2018 11:13:24 +0200

lightning: improve receive in Qt GUI

Diffstat:
Melectrum/gui/qt/main_window.py | 13++++++-------
Melectrum/gui/qt/request_list.py | 33+++++++++++----------------------
2 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -1058,13 +1058,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): i = self.expires_combo.currentIndex() expiration = list(map(lambda x: x[1], expiration_values))[i] if self.receive_type.currentIndex() == 1: - self.create_lightning_request(amount, message, expiration) + key = self.wallet.lnworker.add_invoice(amount, message) else: - self.create_bitcoin_request(amount, message, expiration) + key = self.create_bitcoin_request(amount, message, expiration) + self.address_list.update() + self.clear_receive_tab() self.request_list.update() - - def create_lightning_request(self, amount, message, expiration): - req = self.wallet.lnworker.add_invoice(amount, message) + items = self.request_list.findItems(key, Qt.UserRole|Qt.MatchContains|Qt.MatchRecursive, column=0) + self.request_list.setCurrentItem(items[0]) def create_bitcoin_request(self, amount, message, expiration): addr = self.wallet.get_unused_address() @@ -1089,8 +1090,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): else: self.sign_payment_request(addr) #self.save_request_button.setEnabled(False) - finally: - self.address_list.update() def view_and_paste(self, title, msg, data): dialog = WindowModalDialog(self, title) diff --git a/electrum/gui/qt/request_list.py b/electrum/gui/qt/request_list.py @@ -78,23 +78,14 @@ class RequestList(MyTreeView): if req is None: self.update() return - expires = age(req['time'] + req['exp']) if req.get('exp') else _('Never') - amount = req['amount'] - message = req['memo'] - self.parent.receive_address_e.setText(addr) - #req = self.wallet.receive_requests.get(addr) - #if req is None: - # self.update() - # return - #expires = age(req['time'] + req['exp']) if req.get('exp') else _('Never') - #amount = req['amount'] - #message = self.wallet.labels.get(addr, '') - #self.parent.receive_message_e.setText(message) - #self.parent.receive_amount_e.setAmount(amount) - #self.parent.expires_combo.hide() - #self.parent.expires_label.show() - #self.parent.expires_label.setText(expires) - #self.parent.new_request_button.setEnabled(True) + item = self.model().itemFromIndex(idx.sibling(idx.row(), 0)) + request_type = item.data(Qt.UserRole) + key = str(item.data(Qt.UserRole + 1)) + if request_type == REQUEST_TYPE_BITCOIN: + req = self.parent.get_request_URI(key) + elif request_type == REQUEST_TYPE_LN: + req = self.wallet.lnworker.invoices.get(key) + self.parent.receive_address_e.setText(req) def update(self): self.wallet = self.parent.wallet @@ -122,7 +113,6 @@ class RequestList(MyTreeView): self.model().clear() self.update_headers(self.__class__.headers) - self.hideColumn(self.Columns.ADDRESS) for req in self.wallet.get_sorted_requests(self.config): address = req['address'] if address not in domain: @@ -136,8 +126,7 @@ class RequestList(MyTreeView): signature = req.get('sig') requestor = req.get('name', '') amount_str = self.parent.format_amount(amount) if amount else "" - URI = self.parent.get_request_URI(address) - labels = [date, URI, '', message, amount_str, pr_tooltips.get(status,'')] + labels = [date, address, '', message, amount_str, pr_tooltips.get(status,'')] items = [QStandardItem(e) for e in labels] self.set_editability(items) if signature is not None: @@ -201,7 +190,7 @@ class RequestList(MyTreeView): if column == self.Columns.AMOUNT: column_data = column_data.strip() menu.addAction(_("Copy {}").format(column_title), lambda: self.parent.app.clipboard().setText(column_data)) - menu.addAction(_("Copy URI"), lambda: self.parent.view_and_paste('URI', '', self.parent.get_request_URI(addr))) + menu.addAction(_("Copy"), lambda: self.parent.app.clipboard().setText(req)) menu.addAction(_("Save as BIP70 file"), lambda: self.parent.export_payment_request(addr)) menu.addAction(_("Delete"), lambda: self.parent.delete_payment_request(addr)) run_hook('receive_list_menu', menu, addr) @@ -218,6 +207,6 @@ class RequestList(MyTreeView): menu = QMenu(self) if column != 2: menu.addAction(_("Copy {}").format(column_title), lambda: self.parent.app.clipboard().setText(column_data)) - menu.addAction(_("Copy URI"), lambda: self.parent.view_and_paste('URI', '', req)) + menu.addAction(_("Copy"), lambda: self.parent.app.clipboard().setText(req)) menu.addAction(_("Delete"), lambda: self.parent.delete_lightning_payreq(payreq_key)) return menu