URI: 
       tlnworker: save outgoing invoice when initiating payment - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 8274a963e6e5c9ce11af198f6ca23d21b1c5ba41
   DIR parent 98e85fd16d9eb15a98d6fe7262d54d92f744502a
  HTML Author: Janus <ysangkok@gmail.com>
       Date:   Fri,  8 Feb 2019 20:32:06 +0100
       
       lnworker: save outgoing invoice when initiating payment
       
       Diffstat:
         M electrum/gui/qt/invoice_list.py     |       1 +
         M electrum/gui/qt/main_window.py      |       2 --
         M electrum/lnworker.py                |       5 +++--
         M electrum/tests/test_lnbase.py       |       5 ++++-
       
       4 files changed, 8 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/electrum/gui/qt/invoice_list.py b/electrum/gui/qt/invoice_list.py
       t@@ -33,6 +33,7 @@ from electrum.i18n import _
        from electrum.util import format_time, pr_tooltips, PR_UNPAID
        from electrum.lnutil import lndecode
        from electrum.bitcoin import COIN
       +from electrum import constants
        
        from .util import (MyTreeView, read_QIcon, MONOSPACE_FONT, PR_UNPAID,
                           pr_tooltips, import_meta_gui, export_meta_gui, pr_icons)
   DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
       t@@ -1948,8 +1948,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
                #self.amount_e.textEdited.emit("")
                self.payto_e.is_lightning = True
                self.show_send_tab_onchain_fees(False)
       -        # save
       -        self.wallet.lnworker.save_invoice(None, invoice, SENT)
        
            def show_send_tab_onchain_fees(self, b: bool):
                self.feecontrol_fields.setVisible(b)
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -465,14 +465,15 @@ class LNWorker(PrintError):
                peer = self.peers[route[0].node_id]
                if not self.get_channel_by_short_id(route[0].short_channel_id):
                    assert False, 'Found route with short channel ID we don\'t have: ' + repr(route[0].short_channel_id)
       -        return addr, peer, self._pay_to_route(route, addr)
       +        return addr, peer, self._pay_to_route(route, addr, invoice)
        
       -    async def _pay_to_route(self, route, addr):
       +    async def _pay_to_route(self, route, addr, pay_req):
                short_channel_id = route[0].short_channel_id
                chan = self.get_channel_by_short_id(short_channel_id)
                if not chan:
                    raise Exception("PathFinder returned path with short_channel_id {} that is not in channel list".format(bh2u(short_channel_id)))
                peer = self.peers[route[0].node_id]
       +        self.save_invoice(None, pay_req, SENT)
                htlc = await peer.pay(route, chan, int(addr.amount * COIN * 1000), addr.paymenthash, addr.get_min_final_cltv_expiry())
                self.network.trigger_callback('htlc_added', htlc, addr, SENT)
        
   DIR diff --git a/electrum/tests/test_lnbase.py b/electrum/tests/test_lnbase.py
       t@@ -109,6 +109,9 @@ class MockLNWorker:
            def on_channels_updated(self):
                pass
        
       +    def save_invoice(*args):
       +        pass
       +
            get_invoice = LNWorker.get_invoice
            _create_route_from_invoice = LNWorker._create_route_from_invoice
            _check_invoice = staticmethod(LNWorker._check_invoice)
       t@@ -243,7 +246,7 @@ class TestPeer(unittest.TestCase):
                # AssertionError is ok since we shouldn't use old routes, and the
                # route finding should fail when channel is closed
                with self.assertRaises(AssertionError):
       -            run(asyncio.gather(w1._pay_to_route(route, addr), p1._main_loop(), p2._main_loop()))
       +            run(asyncio.gather(w1._pay_to_route(route, addr, pay_req), p1._main_loop(), p2._main_loop()))
        
        def run(coro):
            asyncio.get_event_loop().run_until_complete(coro)