mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
lnpeer: shutdown should wait until no HTLCs remain
in either ctx
This commit is contained in:
parent
2e38bcf416
commit
a9239bd40f
1 changed files with 3 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue