URI: 
       tqt: add clear button to receive tab, show invoice right after it is added - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 0913194a53dbc405ff70727d1572df06aedeb292
   DIR parent 234591624e338ec2d9e966e9121cf3cbaa4e03fc
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Thu,  6 Jun 2019 09:50:07 +0200
       
       qt: add clear button to receive tab, show invoice right after it is added
       
       Diffstat:
         M electrum/commands.py                |       4 +++-
         M electrum/gui/qt/main_window.py      |      14 ++++++--------
         M electrum/lnworker.py                |       2 +-
       
       3 files changed, 10 insertions(+), 10 deletions(-)
       ---
   DIR diff --git a/electrum/commands.py b/electrum/commands.py
       t@@ -786,7 +786,9 @@ class Commands:
            @command('wn')
            def addinvoice(self, requested_amount, message):
                # using requested_amount because it is documented in param_descriptions
       -        return self.lnworker.add_invoice(satoshis(requested_amount), message)
       +        payment_hash = self.lnworker.add_invoice(satoshis(requested_amount), message)
       +        invoice, direction, is_paid = self.lnworker.invoices[bh2u(payment_hash)]
       +        return invoice
        
            @command('w')
            def nodeid(self):
   DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
       t@@ -963,11 +963,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
                self.expires_label.hide()
                grid.addWidget(self.expires_label, 2, 1)
        
       +        self.clear_invoice_button = QPushButton(_('Clear'))
       +        self.clear_invoice_button.clicked.connect(self.clear_receive_tab)
                self.create_invoice_button = QPushButton(_('On-chain'))
                self.create_invoice_button.setIcon(read_QIcon("bitcoin.png"))
                self.create_invoice_button.clicked.connect(lambda: self.create_invoice(False))
                self.receive_buttons = buttons = QHBoxLayout()
                buttons.addStretch(1)
       +        buttons.addWidget(self.clear_invoice_button)
                buttons.addWidget(self.create_invoice_button)
                if self.config.get('lightning'):
                    self.create_lightning_invoice_button = QPushButton(_('Lightning'))
       t@@ -1076,11 +1079,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
                i = self.expires_combo.currentIndex()
                expiration = list(map(lambda x: x[1], expiration_values))[i]
                if is_lightning:
       -            key = self.wallet.lnworker.add_invoice(amount, message)
       +            payment_hash = self.wallet.lnworker.add_invoice(amount, message)
       +            key = bh2u(payment_hash)
                else:
                    key = self.create_bitcoin_request(amount, message, expiration)
                    self.address_list.update()
       -        self.clear_receive_tab()
                self.request_list.update()
                self.request_list.select_key(key)
        
       t@@ -1130,12 +1133,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
                self.receive_amount_e.setAmount(None)
        
            def clear_receive_tab(self):
       -        try:
       -            addr = self.wallet.get_receiving_address() or ''
       -        except InternalAddressCorruption as e:
       -            self.show_error(str(e))
       -            addr = ''
       -        self.receive_address_e.setText(addr)
       +        self.receive_address_e.setText('')
                self.receive_message_e.setText('')
                self.receive_amount_e.setAmount(None)
                self.expires_label.hide()
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -781,7 +781,7 @@ class LNWallet(LNWorker):
                self.save_invoice(payment_hash, invoice, RECEIVED, is_paid=False)
                self.save_preimage(payment_hash, payment_preimage)
                self.wallet.set_label(bh2u(payment_hash), message)
       -        return invoice
       +        return payment_hash
        
            def save_preimage(self, payment_hash: bytes, preimage: bytes):
                assert sha256(preimage) == payment_hash