Qt: add option to request force close of channel
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import Sequence, Optional, Dict
|
|||||||
from PyQt5 import QtCore, QtGui
|
from PyQt5 import QtCore, QtGui
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import (QMenu, QHBoxLayout, QLabel, QVBoxLayout, QGridLayout, QLineEdit,
|
from PyQt5.QtWidgets import (QMenu, QHBoxLayout, QLabel, QVBoxLayout, QGridLayout, QLineEdit,
|
||||||
QPushButton, QAbstractItemView, QComboBox)
|
QPushButton, QAbstractItemView, QComboBox, QCheckBox)
|
||||||
from PyQt5.QtGui import QFont, QStandardItem, QBrush
|
from PyQt5.QtGui import QFont, QStandardItem, QBrush
|
||||||
|
|
||||||
from electrum.util import bh2u, NotEnoughFunds, NoDynamicFeeEstimates
|
from electrum.util import bh2u, NotEnoughFunds, NoDynamicFeeEstimates
|
||||||
@@ -104,11 +104,23 @@ class ChannelsList(MyTreeView):
|
|||||||
self.main_window.show_error('Failed to close channel:\n{}'.format(repr(e)))
|
self.main_window.show_error('Failed to close channel:\n{}'.format(repr(e)))
|
||||||
|
|
||||||
def close_channel(self, channel_id):
|
def close_channel(self, channel_id):
|
||||||
|
self.is_force_close = False
|
||||||
msg = _('Close channel?')
|
msg = _('Close channel?')
|
||||||
if not self.parent.question(msg):
|
force_cb = QCheckBox('Request force close from remote peer')
|
||||||
|
tooltip = _(
|
||||||
|
'If you check this option, your node will pretend that it has lost its data and ask the remote node to broadcast their latest state. '
|
||||||
|
'Doing so from time to time helps make sure that nodes are honest, because your node can punish them if they broadcast a revoked state.')
|
||||||
|
def on_checked(b):
|
||||||
|
self.is_force_close = bool(b)
|
||||||
|
force_cb.stateChanged.connect(on_checked)
|
||||||
|
force_cb.setToolTip(tooltip)
|
||||||
|
if not self.parent.question(msg, checkbox=force_cb):
|
||||||
return
|
return
|
||||||
def task():
|
def task():
|
||||||
coro = self.lnworker.close_channel(channel_id)
|
if self.is_force_close:
|
||||||
|
coro = self.lnworker.request_remote_force_close(channel_id)
|
||||||
|
else:
|
||||||
|
coro = self.lnworker.close_channel(channel_id)
|
||||||
return self.network.run_from_another_thread(coro)
|
return self.network.run_from_another_thread(coro)
|
||||||
WaitingDialog(self, 'please wait..', task, self.on_success, self.on_failure)
|
WaitingDialog(self, 'please wait..', task, self.on_success, self.on_failure)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user