From df612fa010d0bf1aef6309028940075d71ac5392 Mon Sep 17 00:00:00 2001 From: f321x Date: Fri, 28 Nov 2025 17:06:07 +0100 Subject: [PATCH] lnworker: allow overwriting amount of sent payment info Allows replacing a saved `PaymentInfo` of `SENT` direction if the old one is not yet paid. This allows the user to retry paying a 0 amount invoice with different amount if the previous attempt failed. --- electrum/lnworker.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index f96640cb1..9a37fef6f 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -2553,9 +2553,15 @@ class LNWallet(LNWorker): if old_info := self.get_payment_info(payment_hash=info.payment_hash, direction=info.direction): if info == old_info: return # already saved - if info.direction == SENT: - # allow saving of newer PaymentInfo if it is a sending attempt - old_info = dataclasses.replace(old_info, creation_ts=info.creation_ts) + if info.direction == SENT and old_info.status in (PR_UNPAID, PR_FAILED): + # allow saving of newer PaymentInfo if it is a sending attempt and the previous + # payment failed or was not yet attempted + old_info = dataclasses.replace( + old_info, + creation_ts=info.creation_ts, + status=info.status, + amount_msat=info.amount_msat, # might retrying to pay 0 amount invoice + ) if info != dataclasses.replace(old_info, status=info.status): # differs more than in status. let's fail raise Exception(f"payment_hash already in use: {info=} != {old_info=}")