URI: 
       tremove our closed channels from channeldb. note some FIXMEs - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 7edba633413b48e2ffdaa5dc61ece8d8c4c915fe
   DIR parent 08d20ce187dc89c8d4eefe11f44b5d8e3a897cf1
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Thu, 16 Aug 2018 15:58:02 +0200
       
       remove our closed channels from channeldb. note some FIXMEs
       
       payment were attempting to use the closed channels.
       
       Diffstat:
         M electrum/lnbase.py                  |      11 +++++++++--
         M electrum/lnworker.py                |       1 +
       
       2 files changed, 10 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/electrum/lnbase.py b/electrum/lnbase.py
       t@@ -748,6 +748,7 @@ class Peer(PrintError):
            def mark_open(self, chan):
                if chan.get_state() == "OPEN":
                    return
       +        # NOTE: even closed channels will be temporarily marked "OPEN"
                assert chan.local_state.funding_locked_received
                chan.set_state("OPEN")
                self.network.trigger_callback('channel', chan)
       t@@ -833,7 +834,8 @@ class Peer(PrintError):
        
            @aiosafe
            async def pay(self, path, chan, amount_msat, payment_hash, pubkey_in_invoice, min_final_cltv_expiry):
       -        assert chan.get_state() == "OPEN"
       +        # FIXME aiosafe is breaking "raise PaymentFailure"
       +        assert chan.get_state() == "OPEN", chan.get_state()
                assert amount_msat > 0, "amount_msat is not greater zero"
        
                height = self.network.get_local_height()
       t@@ -856,10 +858,15 @@ class Peer(PrintError):
                msat_remote = chan.remote_state.amount_msat + amount_msat
                htlc = UpdateAddHtlc(amount_msat, payment_hash, final_cltv_expiry_with_deltas)
        
       +        # FIXME if we raise here, this channel will not get blacklisted, and the payment can never succeed,
       +        # as we will just keep retrying this same path. using the current blacklisting is not a solution as
       +        # then no other payment can use this channel either.
       +        # we need finer blacklisting -- e.g. a blacklist for just this "payment session"?
       +        # or blacklist entries could store an msat value and also expire
                if len(chan.htlcs_in_local) + 1 > chan.remote_config.max_accepted_htlcs:
                    raise PaymentFailure('too many HTLCs already in channel')
                if chan.htlcsum(chan.htlcs_in_local) + amount_msat > chan.remote_config.max_htlc_value_in_flight_msat:
       -            raise PaymentFailure('HTLC value sum would exceed max allowed')
       +            raise PaymentFailure('HTLC value sum would exceed max allowed: {} msat'.format(chan.remote_config.max_htlc_value_in_flight_msat))
                if msat_local < 0:
                    # FIXME what about channel_reserve_satoshis? will the remote fail the channel if we go below? test.
                    raise PaymentFailure('not enough local balance')
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -124,6 +124,7 @@ class LNWorker(PrintError):
                if chan.funding_outpoint not in outpoints:
                    chan.set_funding_txo_spentness(True)
                    chan.set_state("CLOSED")
       +            self.channel_db.remove_channel(chan.short_channel_id)
                    # FIXME is this properly GC-ed? (or too soon?)
                    LNChanCloseHandler(self.network, self.wallet, chan)
                else: