Browse Source

lnsweep: detect incomplete MPP using mpp status instead of get_payment_status

get_payment_status is not set in the case of a hold invvoice
master
ThomasV 1 year ago
parent
commit
4420944b76
  1. 8
      electrum/lnsweep.py
  2. 5
      electrum/lnworker.py

8
electrum/lnsweep.py

@ -297,11 +297,13 @@ def create_sweeptxs_for_our_ctx(
ctn=ctn)
for (direction, htlc), (ctx_output_idx, htlc_relative_idx) in htlc_to_ctx_output_idx_map.items():
if direction == RECEIVED:
if chan.lnworker.get_payment_status(htlc.payment_hash) == PR_PAID:
preimage = chan.lnworker.get_preimage(htlc.payment_hash)
else:
if chan.lnworker.is_incomplete_mpp(htlc.payment_hash):
# do not redeem this, it might publish the preimage of an incomplete MPP
continue
preimage = chan.lnworker.get_preimage(htlc.payment_hash)
if not preimage:
# we might not have the preimage if this is a hold invoice
continue
else:
preimage = None
create_txns_for_htlc(

5
electrum/lnworker.py

@ -2332,6 +2332,11 @@ class LNWallet(LNWorker):
total = sum([_htlc.amount_msat for scid, _htlc in mpp_status.htlc_set])
return total >= mpp_status.expected_msat
def is_incomplete_mpp(self, payment_hash: bytes) -> bool:
payment_key = self._get_payment_key(payment_hash)
status = self.received_mpp_htlcs.get(payment_key.hex())
return status and status.resolution == RecvMPPResolution.WAITING
def get_first_timestamp_of_mpp(self, payment_key: bytes) -> int:
mpp_status = self.received_mpp_htlcs.get(payment_key.hex())
if not mpp_status:

Loading…
Cancel
Save