1
0

LNWorker: do not save PR_INFLIGHT status, detect it on startup instead

This commit is contained in:
ThomasV
2021-02-04 15:48:00 +01:00
parent 51455c9d9a
commit c0bf9b4509
3 changed files with 30 additions and 30 deletions

View File

@@ -670,27 +670,19 @@ class Channel(AbstractChannel):
def get_next_feerate(self, subject: HTLCOwner) -> int:
return self.hm.get_feerate_in_next_ctx(subject)
def get_payments(self):
out = []
for direction, htlc in self.hm.all_htlcs_ever():
htlc_proposer = LOCAL if direction is SENT else REMOTE
if self.hm.was_htlc_failed(htlc_id=htlc.htlc_id, htlc_proposer=htlc_proposer):
status = 'failed'
elif self.hm.was_htlc_preimage_released(htlc_id=htlc.htlc_id, htlc_proposer=htlc_proposer):
status = 'settled'
else:
status = 'inflight'
rhash = htlc.payment_hash.hex()
out.append((rhash, self.channel_id, htlc, direction, status))
return out
def get_settled_payments(self):
def get_payments(self, status=None):
out = defaultdict(list)
for direction, htlc in self.hm.all_htlcs_ever():
htlc_proposer = LOCAL if direction is SENT else REMOTE
if self.hm.was_htlc_preimage_released(htlc_id=htlc.htlc_id, htlc_proposer=htlc_proposer):
rhash = htlc.payment_hash.hex()
out[rhash].append((self.channel_id, htlc, direction))
if self.hm.was_htlc_failed(htlc_id=htlc.htlc_id, htlc_proposer=htlc_proposer):
_status = 'failed'
elif self.hm.was_htlc_preimage_released(htlc_id=htlc.htlc_id, htlc_proposer=htlc_proposer):
_status = 'settled'
else:
_status = 'inflight'
if status and status != _status:
continue
out[htlc.payment_hash].append((self.channel_id, htlc, direction, _status))
return out
def open_with_first_pcp(self, remote_pcp: bytes, remote_sig: bytes) -> None: