@ -160,15 +160,19 @@ class QEChannelDetails(AuthMixin, QObject, QtEventListener):
@pyqtProperty ( bool , notify = channelChanged )
@pyqtProperty ( bool , notify = channelChanged )
def canClose ( self ) :
def canClose ( self ) :
return self . canCoopClose or self . canForceClose
return self . canCoopClose or self . canLocalForceClose or self . canRequest ForceClose
@pyqtProperty ( bool , notify = channelChanged )
@pyqtProperty ( bool , notify = channelChanged )
def canCoopClose ( self ) :
def canCoopClose ( self ) :
return ChanCloseOption . COOP_CLOSE in self . _channel . get_close_options ( )
return ChanCloseOption . COOP_CLOSE in self . _channel . get_close_options ( )
@pyqtProperty ( bool , notify = channelChanged )
@pyqtProperty ( bool , notify = channelChanged )
def canForceClose ( self ) :
def canLocalForceClose ( self ) :
return any ( [ o in [ ChanCloseOption . LOCAL_FCLOSE , ChanCloseOption . REQUEST_REMOTE_FCLOSE ] for o in self . _channel . get_close_options ( ) ] )
return ChanCloseOption . LOCAL_FCLOSE in self . _channel . get_close_options ( )
@pyqtProperty ( bool , notify = channelChanged )
def canRequestForceClose ( self ) :
return ChanCloseOption . REQUEST_REMOTE_FCLOSE in self . _channel . get_close_options ( )
@pyqtProperty ( bool , notify = channelChanged )
@pyqtProperty ( bool , notify = channelChanged )
def canDelete ( self ) :
def canDelete ( self ) :
@ -234,6 +238,18 @@ class QEChannelDetails(AuthMixin, QObject, QtEventListener):
def do_close_channel ( self , closetype ) :
def do_close_channel ( self , closetype ) :
channel_id = self . _channel . channel_id
channel_id = self . _channel . channel_id
def handle_result ( success : bool , msg : str = ' ' ) :
try :
if success :
self . channelCloseSuccess . emit ( )
else :
self . channelCloseFailed . emit ( msg )
self . _is_closing = False
self . isClosingChanged . emit ( )
except RuntimeError : # QEChannelDetails might be deleted at this point if the user closed the dialog.
pass
def do_close ( ) :
def do_close ( ) :
try :
try :
self . _is_closing = True
self . _is_closing = True
@ -245,13 +261,10 @@ class QEChannelDetails(AuthMixin, QObject, QtEventListener):
else :
else :
self . _wallet . wallet . network . run_from_another_thread ( self . _wallet . wallet . lnworker . close_channel ( channel_id ) )
self . _wallet . wallet . network . run_from_another_thread ( self . _wallet . wallet . lnworker . close_channel ( channel_id ) )
self . _logger . debug ( ' Channel close successful ' )
self . _logger . debug ( ' Channel close successful ' )
self . channelCloseSuccess . emit ( )
handle_result ( True )
except Exception as e :
except Exception as e :
self . _logger . exception ( " Could not close channel: " + repr ( e ) )
self . _logger . exception ( " Could not close channel: " + repr ( e ) )
self . channelCloseFailed . emit ( _ ( ' Could not close channel: ' ) + repr ( e ) )
handle_result ( False , _ ( ' Could not close channel: ' ) + repr ( e ) )
finally :
self . _is_closing = False
self . isClosingChanged . emit ( )
threading . Thread ( target = do_close , daemon = True ) . start ( )
threading . Thread ( target = do_close , daemon = True ) . start ( )