URI: 
       tfix #6096: bugfix for creating zero amount LN invoice - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 12d771737afe87f520ffefb7648fd3878076b923
   DIR parent 8f4c384aad8531d1acecffde5583deefc251fc50
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Sat, 18 Apr 2020 05:56:12 +0200
       
       fix #6096: bugfix for creating zero amount LN invoice
       
       (also there was a unit-mismatch here...)
       
       Diffstat:
         M electrum/lnworker.py                |      10 +++++++---
       
       1 file changed, 7 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -1051,7 +1051,7 @@ class LNWallet(LNWorker):
                    raise Exception(_("add invoice timed out"))
        
            @log_exceptions
       -    async def _add_request_coro(self, amount_sat, message, expiry: int):
       +    async def _add_request_coro(self, amount_sat: Optional[int], message, expiry: int):
                timestamp = int(time.time())
                routing_hints = await self._calc_routing_hints_for_invoice(amount_sat)
                if not routing_hints:
       t@@ -1190,16 +1190,20 @@ class LNWallet(LNWorker):
                util.trigger_callback('request_status', payment_hash.hex(), PR_PAID)
                util.trigger_callback('ln_payment_completed', payment_hash, chan.channel_id)
        
       -    async def _calc_routing_hints_for_invoice(self, amount_sat):
       +    async def _calc_routing_hints_for_invoice(self, amount_sat: Optional[int]):
                """calculate routing hints (BOLT-11 'r' field)"""
                routing_hints = []
                with self.lock:
                    channels = list(self.channels.values())
                scid_to_my_channels = {chan.short_channel_id: chan for chan in channels
                                       if chan.short_channel_id is not None}
       +        if amount_sat:
       +            amount_msat = 1000 * amount_sat
       +        else:  # for no amt invoices, check if channel can receive at least 1 sat:
       +            amount_msat = 1
                # note: currently we add *all* our channels; but this might be a privacy leak?
                for chan in channels:
       -            if not chan.can_receive(amount_sat, check_frozen=True):
       +            if not chan.can_receive(amount_msat=amount_msat, check_frozen=True):
                        continue
                    chan_id = chan.short_channel_id
                    assert isinstance(chan_id, bytes), chan_id