qml: don't crash when initiating swap when swap service is not available
This commit is contained in:
@@ -32,6 +32,7 @@ class QESwapHelper(AuthMixin, QObject):
|
|||||||
_miningfee = QEAmount()
|
_miningfee = QEAmount()
|
||||||
_isReverse = False
|
_isReverse = False
|
||||||
|
|
||||||
|
_service_available = False
|
||||||
_send_amount = 0
|
_send_amount = 0
|
||||||
_receive_amount = 0
|
_receive_amount = 0
|
||||||
|
|
||||||
@@ -179,7 +180,13 @@ class QESwapHelper(AuthMixin, QObject):
|
|||||||
def init_swap_slider_range(self):
|
def init_swap_slider_range(self):
|
||||||
lnworker = self._wallet.wallet.lnworker
|
lnworker = self._wallet.wallet.lnworker
|
||||||
swap_manager = lnworker.swap_manager
|
swap_manager = lnworker.swap_manager
|
||||||
asyncio.run(swap_manager.get_pairs())
|
try:
|
||||||
|
asyncio.run(swap_manager.get_pairs())
|
||||||
|
self._service_available = True
|
||||||
|
except Exception as e:
|
||||||
|
self._logger.error(f'could not get pairs for swap: {repr(e)}')
|
||||||
|
return
|
||||||
|
|
||||||
"""Sets the minimal and maximal amount that can be swapped for the swap
|
"""Sets the minimal and maximal amount that can be swapped for the swap
|
||||||
slider."""
|
slider."""
|
||||||
# tx is updated again afterwards with send_amount in case of normal swap
|
# tx is updated again afterwards with send_amount in case of normal swap
|
||||||
@@ -223,6 +230,9 @@ class QESwapHelper(AuthMixin, QObject):
|
|||||||
self.valid = False
|
self.valid = False
|
||||||
|
|
||||||
def swap_slider_moved(self):
|
def swap_slider_moved(self):
|
||||||
|
if not self._service_available:
|
||||||
|
return
|
||||||
|
|
||||||
position = int(self._sliderPos)
|
position = int(self._sliderPos)
|
||||||
|
|
||||||
swap_manager = self._wallet.wallet.lnworker.swap_manager
|
swap_manager = self._wallet.wallet.lnworker.swap_manager
|
||||||
|
|||||||
Reference in New Issue
Block a user