electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6b6097a4534cf4cb40229adc40576a2375d1c812
parent bd45f3f1c8fbcb99462daf3fc56b69462d7f40f7
Author: Janus <ysangkok@gmail.com>
Date:   Thu, 24 Jan 2019 18:21:46 +0100

ln: add closechannel cli command

Diffstat:
Melectrum/commands.py | 8++++++++
Melectrum/lnbase.py | 3++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/electrum/commands.py b/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 diff --git a/electrum/lnbase.py b/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))