From 3a5d19de7dfe0c15485ee50523ae080e6bd28122 Mon Sep 17 00:00:00 2001 From: Janus Date: Wed, 26 Sep 2018 19:15:59 +0200 Subject: [PATCH] ln: commit fee updates as soon as possible --- electrum/lnbase.py | 7 ++++++- electrum/lnworker.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/electrum/lnbase.py b/electrum/lnbase.py index 763dd01b1..a89787b91 100644 --- a/electrum/lnbase.py +++ b/electrum/lnbase.py @@ -1040,7 +1040,7 @@ class Peer(PrintError): channel_id = payload["channel_id"] self.channels[channel_id].receive_update_fee(int.from_bytes(payload["feerate_per_kw"], "big")) - def on_bitcoin_fee_update(self, chan): + async def bitcoin_fee_update(self, chan): """ called when our fee estimates change """ @@ -1062,6 +1062,11 @@ class Peer(PrintError): return self.send_message(gen_msg("update_fee", channel_id=chan.channel_id, feerate_per_kw=feerate_per_kw)) + sig_64, htlc_sigs = chan.sign_next_commitment() + self.send_message(gen_msg("commitment_signed", channel_id=chan.channel_id, signature=sig_64, num_htlcs=len(htlc_sigs), htlc_signature=b"".join(htlc_sigs))) + await self.receive_revoke(chan) + await self.receive_commitment(chan) + self.revoke(chan) self.lnworker.save_channel(chan) def current_feerate_per_kw(self): diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 90a0cbb36..5d689bc8e 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -150,7 +150,7 @@ class LNWorker(PrintError): self.print_error("peer not found for {}".format(bh2u(chan.node_id))) return if event == 'fee': - peer.on_bitcoin_fee_update(chan) + await peer.bitcoin_fee_update(chan) conf = self.wallet.get_tx_height(chan.funding_outpoint.txid).conf peer.on_network_update(chan, conf)