commit a9239bd40f2014cb2cc054728fcdb7f680e930bb
parent 2e38bcf4160c714b7f8a7bdcd26445b6f09371ac
Author: SomberNight <somber.night@protonmail.com>
Date: Wed, 14 Aug 2019 21:47:57 +0200
lnpeer: shutdown should wait until no HTLCs remain
in either ctx
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
@@ -1447,12 +1447,13 @@ class Peer(Logger):
async def _shutdown(self, chan: Channel, payload, is_local):
# set state so that we stop accepting HTLCs
chan.set_state('CLOSING')
- while len(chan.hm.htlcs_by_direction(LOCAL, RECEIVED)) > 0:
+ # wait until no HTLCs remain in either commitment transaction
+ while len(chan.hm.htlcs(LOCAL)) + len(chan.hm.htlcs(REMOTE)) > 0:
self.logger.info('waiting for htlcs to settle...')
await asyncio.sleep(1)
our_fee = chan.pending_local_fee()
scriptpubkey = bfh(bitcoin.address_to_script(chan.sweep_address))
- # negociate fee
+ # negotiate fee
while True:
our_sig, closing_tx = chan.make_closing_tx(scriptpubkey, payload['scriptpubkey'], fee_sat=our_fee)
self.send_message('closing_signed', channel_id=chan.channel_id, fee_satoshis=our_fee, signature=our_sig)