Browse Source

move feerate warning to lnpeer

hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
2c617c3b00
  1. 15
      electrum/lnpeer.py
  2. 8
      electrum/lnworker.py

15
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")

8
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

Loading…
Cancel
Save