Browse Source

ln: add closechannel cli command

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
Janus 6 years ago
committed by ThomasV
parent
commit
6b6097a453
  1. 8
      electrum/commands.py
  2. 3
      electrum/lnbase.py

8
electrum/commands.py

@ -808,6 +808,14 @@ class Commands:
def listinvoices(self):
return "\n".join(self.wallet.lnworker.list_invoices())
@command('wn')
def closechannel(self, channel_point, force=False):
chan_id = bytes(reversed(bfh(channel_point)))
if force:
return self.network.run_from_another_thread(self.wallet.lnworker.force_close_channel(chan_id))
else:
return self.network.run_from_another_thread(self.wallet.lnworker.close_channel(chan_id))
def eval_bool(x: str) -> bool:
if x == 'false': return False
if x == 'true': return True

3
electrum/lnbase.py

@ -1180,7 +1180,8 @@ class Peer(PrintError):
async def _shutdown(self, chan: Channel, payload):
# set state so that we stop accepting HTLCs
chan.set_state('CLOSING')
while len(chan.htlcs(LOCAL, only_pending=True)) > 0:
while len(chan.hm.htlcs_by_direction(LOCAL, RECEIVED)) > 0:
self.print_error('waiting for htlcs to settle...')
await asyncio.sleep(1)
our_fee = chan.pending_local_fee()
scriptpubkey = bfh(bitcoin.address_to_script(chan.sweep_address))

Loading…
Cancel
Save