tln fees: avoid resending same fee update before it has been committed to, docs - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 5753cf9e050f9297f10afa87215b2906f9f0753f DIR parent 22b06ddec29b2b8345e4e92b8ad757936f9b6ed8 HTML Author: Janus <ysangkok@gmail.com> Date: Wed, 26 Sep 2018 15:08:57 +0200 ln fees: avoid resending same fee update before it has been committed to, docs Diffstat: M electrum/lnbase.py | 7 ++++--- M electrum/lnhtlc.py | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) --- DIR diff --git a/electrum/lnbase.py b/electrum/lnbase.py t@@ -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: DIR diff --git a/electrum/lnhtlc.py b/electrum/lnhtlc.py t@@ -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): t@@ -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}