electrum

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

commit 2c617c3b00e961284f5851df34b77b961fc88abe
parent ee01ca352fb581d45855ab92992d0ea214c7083d
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  6 Mar 2020 18:14:00 +0100

move feerate warning to lnpeer

Diffstat:
Melectrum/lnpeer.py | 15++++++++++++---
Melectrum/lnworker.py | 8+-------
2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -1249,16 +1249,25 @@ class Peer(Logger): chan = self.channels[channel_id] chan.update_fee(feerate, False) - async def bitcoin_fee_update(self, chan: Channel): + async def maybe_update_fee(self, chan: Channel): """ called when our fee estimates change """ if not chan.can_send_ctx_updates(): return + feerate_per_kw = self.lnworker.current_feerate_per_kw() if not chan.constraints.is_initiator: - # TODO force close if initiator does not update_fee enough + if constants.net is not constants.BitcoinRegtest: + chan_feerate = chan.get_latest_feerate(LOCAL) + ratio = chan_feerate / feerate_per_kw + if ratio < 0.5: + # Note that we trust the Electrum server about fee rates + # Thus, automated force-closing might not be a good idea + # Maybe we should display something in the GUI instead + self.logger.warning( + f"({chan.get_id_for_log()}) feerate is {chan_feerate} sat/kw, " + f"current recommended feerate is {feerate_per_kw} sat/kw, consider force closing!") return - feerate_per_kw = self.lnworker.current_feerate_per_kw() chan_fee = chan.get_next_feerate(REMOTE) if feerate_per_kw < chan_fee / 2: self.logger.info("FEES HAVE FALLEN") diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -751,7 +751,7 @@ class LNWallet(LNWorker): if peer is None: self.logger.info("peer not found for {}".format(bh2u(chan.node_id))) return - await peer.bitcoin_fee_update(chan) + await peer.maybe_update_fee(chan) conf = self.lnwatcher.get_tx_height(chan.funding_outpoint.txid).conf peer.on_network_update(chan, conf) @@ -1362,12 +1362,6 @@ class LNWallet(LNWorker): for chan in channels: if chan.is_closed(): continue - if constants.net is not constants.BitcoinRegtest: - chan_feerate = chan.get_latest_feerate(LOCAL) - ratio = chan_feerate / self.current_feerate_per_kw() - if ratio < 0.5: - self.logger.warning(f"fee level for channel {bh2u(chan.channel_id)} is {chan_feerate} sat/kiloweight, " - f"current recommended feerate is {self.current_feerate_per_kw()} sat/kiloweight, consider force closing!") # reestablish if not chan.should_try_to_reestablish_peer(): continue