From c4c2123b4b2a0107c20e35daea69ec41e44227b2 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 28 Jun 2023 14:25:53 +0200 Subject: [PATCH] fix bundled payments: - prepayment should be accepted immediately once bundle is here - mpp timeout all parts, but accept only current part --- electrum/lnworker.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 15d6bed85..468596ace 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1923,8 +1923,6 @@ class LNWallet(LNWorker): is_accepted = True elif self.stopping_soon: is_expired = True # try to time out pending HTLCs before shutting down - elif time.time() - first_timestamp > self.MPP_EXPIRY: - is_expired = True elif all([self.is_mpp_amount_reached(x) for x in payment_secrets]): preimage = self.get_preimage(payment_hash) hold_invoice_callback = self.hold_invoice_callbacks.get(payment_hash) @@ -1935,14 +1933,18 @@ class LNWallet(LNWorker): cb(payment_hash) else: is_expired = True - elif bundle is not None: - is_accepted = all([bool(self.get_preimage(x)) for x in bundle]) else: - # trampoline forwarding needs this to return True + # note: preimage will be None for outer trampoline onion is_accepted = True - # set status for the bundle - if is_expired or is_accepted: + elif time.time() - first_timestamp > self.MPP_EXPIRY: + is_expired = True + + if is_accepted: + # accept only the current part of a bundle + self.set_mpp_status(payment_secret, is_expired, is_accepted) + elif is_expired: + # .. but expire all parts for x in payment_secrets: if x in self.received_mpp_htlcs: self.set_mpp_status(x, is_expired, is_accepted)