Browse Source

fix: add request_force_close method

patch-4
ThomasV 4 years ago
parent
commit
bcfcc20363
  1. 2
      electrum/commands.py
  2. 2
      electrum/gui/qt/channels_list.py
  3. 12
      electrum/lnworker.py

2
electrum/commands.py

@ -1099,7 +1099,7 @@ class Commands:
async def request_force_close(self, channel_point, wallet: Abstract_Wallet = None):
txid, index = channel_point.split(':')
chan_id, _ = channel_id_from_funding_tx(txid, int(index))
return await wallet.lnworker.request_force_close_from_backup(chan_id)
return await wallet.lnworker.request_force_close(chan_id)
@command('w')
async def export_channel_backup(self, channel_point, wallet: Abstract_Wallet = None):

2
electrum/gui/qt/channels_list.py

@ -119,7 +119,7 @@ class ChannelsList(MyTreeView):
return
def task():
if self.is_force_close:
coro = self.lnworker.request_remote_force_close(channel_id)
coro = self.lnworker.request_force_close(channel_id)
else:
coro = self.lnworker.close_channel(channel_id)
return self.network.run_from_another_thread(coro)

12
electrum/lnworker.py

@ -2022,6 +2022,18 @@ class LNWallet(LNWorker):
peer = await self.add_peer(connect_str)
await peer.trigger_force_close(channel_id)
async def request_force_close(self, channel_id: bytes):
if channel_id in self.channels:
chan = self.channels[chan_id]
peer = self._peers.get(chan.node_id)
if not peer:
raise Exception('Peer not found')
await peer.trigger_force_close(channel_id)
elif channel_id in self.channel_backups:
await self.request_force_close_from_backup(channel_id)
else:
raise Exception(f'Unknown channel {channel_id.hex()}')
def import_channel_backup(self, data):
assert data.startswith('channel_backup:')
encrypted = data[15:]

Loading…
Cancel
Save