diff --git a/electrum/lnsweep.py b/electrum/lnsweep.py index e879d4dc0..86d227da9 100644 --- a/electrum/lnsweep.py +++ b/electrum/lnsweep.py @@ -297,7 +297,7 @@ 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.is_incomplete_mpp(htlc.payment_hash): + if not chan.lnworker.is_accepted_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) @@ -434,11 +434,13 @@ def create_sweeptxs_for_their_ctx( for (direction, htlc), (ctx_output_idx, htlc_relative_idx) in htlc_to_ctx_output_idx_map.items(): is_received_htlc = direction == RECEIVED if not is_received_htlc and not is_revocation: - if chan.lnworker.get_payment_status(htlc.payment_hash) == PR_PAID: - preimage = chan.lnworker.get_preimage(htlc.payment_hash) - else: + if not chan.lnworker.is_accepted_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_sweeptx_for_htlc( diff --git a/electrum/lnworker.py b/electrum/lnworker.py index dec4dc9dc..8b1d36097 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -2332,10 +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: + def is_accepted_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 + assert status is not None + return status.resolution == RecvMPPResolution.ACCEPTED def get_first_timestamp_of_mpp(self, payment_key: bytes) -> int: mpp_status = self.received_mpp_htlcs.get(payment_key.hex())