From 08ec368baf3cd71aace0c323820e1cfa30e547e8 Mon Sep 17 00:00:00 2001
From: bitromortac <bitromortac@protonmail.com>
Date: Mon, 18 Jan 2021 08:05:29 +0100
Subject: [PATCH] fee-slider: fix dialog crashes for float pos values

---
 electrum/gui/kivy/uix/dialogs/lightning_channels.py | 10 +++++-----
 electrum/simple_config.py                           |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py
index 8e32dcb15..916795f34 100644
--- a/electrum/gui/kivy/uix/dialogs/lightning_channels.py
+++ b/electrum/gui/kivy/uix/dialogs/lightning_channels.py
@@ -1,10 +1,9 @@
 import asyncio
-from typing import TYPE_CHECKING, Optional, Tuple
+from typing import TYPE_CHECKING, Optional, Union
 
 from kivy.lang import Builder
 from kivy.factory import Factory
 from kivy.uix.popup import Popup
-from kivy.clock import Clock
 from .fee_dialog import FeeDialog
 
 from electrum.util import bh2u
@@ -13,7 +12,7 @@ from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id
 from electrum.lnchannel import AbstractChannel, Channel
 from electrum.gui.kivy.i18n import _
 from .question import Question
-from electrum.transaction import PartialTxOutput, PartialTransaction
+from electrum.transaction import PartialTxOutput
 from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates, format_fee_satoshis
 from electrum.lnutil import ln_dummy_address
 
@@ -635,6 +634,7 @@ class SwapDialog(Factory.Popup):
         self.send_amount: Optional[int] = None
         self.receive_amount: Optional[int] = None
         self.tx = None  # only for forward swap
+        self.is_reverse = None
 
         # init swaps and sliders
         asyncio.run(self.swap_manager.get_pairs())
@@ -676,7 +676,7 @@ class SwapDialog(Factory.Popup):
         self.ids.fee_rate.text = f'{fee_per_b} sat/B'
         self.ids.fee_estimate.text = msg
 
-    def update_tx(self, onchain_amount: int):
+    def update_tx(self, onchain_amount: Union[int, str]):
         """Updates the transaction associated with a forward swap."""
         if onchain_amount is None:
             self.tx = None
@@ -688,7 +688,7 @@ class SwapDialog(Factory.Popup):
             self.tx = self.app.wallet.make_unsigned_transaction(
                 coins=coins,
                 outputs=outputs)
-        except (NotEnoughFunds, NoDynamicFeeEstimates) as e:
+        except (NotEnoughFunds, NoDynamicFeeEstimates):
             self.tx = None
             self.ids.ok_button.disabled = True
 
diff --git a/electrum/simple_config.py b/electrum/simple_config.py
index 9bf2284e1..fd495762c 100644
--- a/electrum/simple_config.py
+++ b/electrum/simple_config.py
@@ -325,7 +325,7 @@ class SimpleConfig(Logger):
         slider_pos = max(slider_pos, 0)
         slider_pos = min(slider_pos, len(FEE_ETA_TARGETS))
         if slider_pos < len(FEE_ETA_TARGETS):
-            num_blocks = FEE_ETA_TARGETS[slider_pos]
+            num_blocks = FEE_ETA_TARGETS[int(slider_pos)]
             fee = self.eta_target_to_fee(num_blocks)
         else:
             fee = self.eta_target_to_fee(1)