Browse Source

ln fees: avoid resending same fee update before it has been committed to, docs

regtest_lnd
Janus 6 years ago
committed by SomberNight
parent
commit
393282d038
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 7
      electrum/lnbase.py
  2. 9
      electrum/lnhtlc.py

7
electrum/lnbase.py

@ -1049,12 +1049,13 @@ class Peer(PrintError):
return
feerate_per_kw = self.current_feerate_per_kw()
self.print_error("current feerate", chan.remote_state.feerate)
chan_fee = chan.pending_feerate(REMOTE)
self.print_error("current pending feerate", chan_fee)
self.print_error("new feerate", feerate_per_kw)
if feerate_per_kw < chan.remote_state.feerate / 2:
if feerate_per_kw < chan_fee / 2:
self.print_error("FEES HAVE FALLEN")
chan.update_fee(feerate_per_kw)
elif feerate_per_kw > chan.remote_state.feerate * 2:
elif feerate_per_kw > chan_fee * 2:
self.print_error("FEES HAVE RISEN")
chan.update_fee(feerate_per_kw)
else:

9
electrum/lnhtlc.py

@ -62,9 +62,17 @@ class FeeUpdate:
self.progress[field] = self.height
def is_proposed(self):
"""
returns True when this FeeUpdate has been proposed
at or above the current commitment number of the funder
"""
return self.progress[COMMITTED] is None and self.proposed is not None and self.proposed <= self.height
def had(self, field):
"""
returns true when the progress field given has been
set at the current commitment number of the funder
"""
return self.progress[field] is not None and self.height >= self.progress[field]
def pending_feerate(self, subject):
@ -76,6 +84,7 @@ class FeeUpdate:
return self.rate
if subject == LOCAL and not self.chan.constraints.is_initiator:
return self.rate
# implicit return None
def to_save(self):
return {'rate': self.rate, 'proposed': self.proposed, 'progress': self.progress}

Loading…
Cancel
Save