fix: add request_force_close method
This commit is contained in:
@@ -1099,7 +1099,7 @@ class Commands:
|
|||||||
async def request_force_close(self, channel_point, wallet: Abstract_Wallet = None):
|
async def request_force_close(self, channel_point, wallet: Abstract_Wallet = None):
|
||||||
txid, index = channel_point.split(':')
|
txid, index = channel_point.split(':')
|
||||||
chan_id, _ = channel_id_from_funding_tx(txid, int(index))
|
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')
|
@command('w')
|
||||||
async def export_channel_backup(self, channel_point, wallet: Abstract_Wallet = None):
|
async def export_channel_backup(self, channel_point, wallet: Abstract_Wallet = None):
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class ChannelsList(MyTreeView):
|
|||||||
return
|
return
|
||||||
def task():
|
def task():
|
||||||
if self.is_force_close:
|
if self.is_force_close:
|
||||||
coro = self.lnworker.request_remote_force_close(channel_id)
|
coro = self.lnworker.request_force_close(channel_id)
|
||||||
else:
|
else:
|
||||||
coro = self.lnworker.close_channel(channel_id)
|
coro = self.lnworker.close_channel(channel_id)
|
||||||
return self.network.run_from_another_thread(coro)
|
return self.network.run_from_another_thread(coro)
|
||||||
|
|||||||
@@ -2022,6 +2022,18 @@ class LNWallet(LNWorker):
|
|||||||
peer = await self.add_peer(connect_str)
|
peer = await self.add_peer(connect_str)
|
||||||
await peer.trigger_force_close(channel_id)
|
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):
|
def import_channel_backup(self, data):
|
||||||
assert data.startswith('channel_backup:')
|
assert data.startswith('channel_backup:')
|
||||||
encrypted = data[15:]
|
encrypted = data[15:]
|
||||||
|
|||||||
Reference in New Issue
Block a user