What changed, and why it matters
This commit fixes a bug in LNbits' OpenNode wallet integration where failed invoice payments were incorrectly reported as definitively failed (ok=False) instead of uncertain (ok=None), and adds handling for expired invoices. The change makes payment status reporting more accurate, which could prevent users from being incorrectly told a payment failed when it might still be pending or retriable.
Review downstream consumers of PaymentResponse to ensure they correctly handle ok=None as pending/unknown rather than failed. Consider adding tests for HTTP error paths and expired invoice status mapping. No urgent security patch appears needed beyond applying this fix.
Security signals we found
Incorrect error handling could lead to false negative payment status reporting
State machine mismatch between payment response and status semantics
Potential for double-spend or retry logic confusion if downstream code treats ok=False as final
Evidence from the diff
In lnbits/wallets/opennode.py, the pay_invoice method now returns PaymentResponse(ok=None, error_message=…) instead of ok=False when the OpenNode API returns an HTTP error. This aligns with the wallet’s status-checking semantics where None means ‘unknown/pending’ rather than ‘definitively failed’. Additionally, the get_payment_status method now maps the ‘expired’ status to False. The change is a correctness fix for payment state handling.
Changed components
lnbits/wallets/opennode.pyOpenNodeWallet.pay_invoice()OpenNodeWallet.get_payment_status()Inspect captured patch +3 / −2
diff --git a/lnbits/wallets/opennode.py b/lnbits/wallets/opennode.py
index 91e7156..f053497 100644
--- a/lnbits/wallets/opennode.py
+++ b/lnbits/wallets/opennode.py
@@ -108,7 +108,8 @@ class OpenNodeWallet(Wallet):
if r.is_error:
error_message = r.json()["message"]
- return PaymentResponse(ok=False, error_message=error_message)
+ logger.warning(error_message)
+ return PaymentResponse(ok=None, error_message=error_message)
data = r.json()["data"]
checking_id = data["id"]
@@ -123,7 +124,7 @@ class OpenNodeWallet(Wallet):
if r.is_error:
return PaymentPendingStatus()
data = r.json()["data"]
- statuses = {"processing": None, "paid": True, "unpaid": None}
+ statuses = {"processing": None, "paid": True, "unpaid": None, "expired": False}
return PaymentStatus(statuses[data.get("status")])
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
Why this scored 26/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.