URI: 
       tswaps: show time left until tx can be refunded - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit fa399f34713b49b88e634af6e86806b2f3f8633e
   DIR parent 04fb329c2e8feb02cddcb5f07c22eca0d0cee401
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Wed, 27 May 2020 12:20:00 +0200
       
       swaps: show time left until tx can be refunded
       
       Diffstat:
         M electrum/lnworker.py                |       8 +++++++-
       
       1 file changed, 7 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -682,6 +682,7 @@ class LNWallet(LNWorker):
                    out[closing_txid] = item
                # add submarine swaps
                settled_payments = self.get_settled_payments()
       +        current_height = self.network.get_local_height()
                for preimage_hex, swap_info in self.swap_manager.swaps.items():
                    is_reverse = swap_info.get('invoice')
                    txid = swap_info.get('claim_txid' if is_reverse else 'funding_txid')
       t@@ -694,11 +695,16 @@ class LNWallet(LNWorker):
                        amount_msat, fee_msat, timestamp = self.get_payment_value(info, plist)
                    else:
                        amount_msat = 0
       +            locktime = swap_info.get('timeoutBlockHeight')
       +            delta = current_height - locktime
       +            label = 'Reverse swap' if is_reverse else 'Normal swap'
       +            if delta < 0:
       +                label += f' (refundable in {-delta} blocks)'
                    out[txid] = {
                        'txid': txid,
                        'amount_msat': amount_msat,
                        'type': 'swap',
       -                'label': 'Reverse swap' if is_reverse else 'Normal swap' # TODO: show time left until we can get a refund
       +                'label': label
                    }
                return out