Skip to content

Commit 3dad647

Browse files
committed
lnpeer: reject htlcs for alredy paid invoices
Reject new incoming htlcs for requests that have already been paid before.
1 parent 60d132e commit 3dad647

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

electrum/lnpeer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2580,7 +2580,6 @@ def log_fail_reason(reason: str):
25802580
fw_payment_key=payment_key)
25812581
return None, (payment_key, callback)
25822582

2583-
# TODO don't accept payments twice for same invoice
25842583
info = self.lnworker.get_payment_info(payment_hash)
25852584
if info is None:
25862585
log_fail_reason(f"no payment_info found for RHASH {htlc.payment_hash.hex()}")
@@ -2616,6 +2615,10 @@ def log_fail_reason(reason: str):
26162615
log_fail_reason(f"remaining locktime smaller than requested {blocks_to_expiry=} < {info.min_final_cltv_delta=}")
26172616
raise exc_incorrect_or_unknown_pd
26182617

2618+
if info.status == PR_PAID:
2619+
log_fail_reason(f"invoice has already been paid")
2620+
raise exc_incorrect_or_unknown_pd
2621+
26192622
self.lnworker.verified_pending_htlcs[htlc_key] = None
26202623

26212624
hold_invoice_callback = self.lnworker.hold_invoice_callbacks.get(payment_hash)

0 commit comments

Comments
 (0)