Browse Source

ln: don't save htlcs that are not locked in

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
Janus 6 years ago
committed by ThomasV
parent
commit
878dc17acb
  1. 12
      electrum/lnhtlc.py

12
electrum/lnhtlc.py

@ -659,6 +659,14 @@ class HTLCStateMachine(PrintError):
pending_fee = FeeUpdate(self, rate=feerate) pending_fee = FeeUpdate(self, rate=feerate)
self.fee_mgr.append(pending_fee) self.fee_mgr.append(pending_fee)
@staticmethod
def remove_unlocked(log):
copy = []
for i in log:
if type(i) is not UpdateAddHtlc or i.locked_in[LOCAL] is not None or i.locked_in[REMOTE] is not None:
copy.append(i)
return copy
def to_save(self): def to_save(self):
return { return {
"local_config": self.local_config, "local_config": self.local_config,
@ -671,8 +679,8 @@ class HTLCStateMachine(PrintError):
"funding_outpoint": self.funding_outpoint, "funding_outpoint": self.funding_outpoint,
"node_id": self.node_id, "node_id": self.node_id,
"remote_commitment_to_be_revoked": str(self.remote_commitment_to_be_revoked), "remote_commitment_to_be_revoked": str(self.remote_commitment_to_be_revoked),
"remote_log": [(type(x).__name__, x) for x in self.log[REMOTE]], "remote_log": [(type(x).__name__, x) for x in self.remove_unlocked(self.log[REMOTE])],
"local_log": [(type(x).__name__, x) for x in self.log[LOCAL]], "local_log": [(type(x).__name__, x) for x in self.remove_unlocked(self.log[LOCAL])],
"fee_updates": [x.to_save() for x in self.fee_mgr], "fee_updates": [x.to_save() for x in self.fee_mgr],
"onion_keys": {str(k): bh2u(v) for k, v in self.onion_keys.items()}, "onion_keys": {str(k): bh2u(v) for k, v in self.onion_keys.items()},
} }

Loading…
Cancel
Save