fix[8c7f]: keep unrecorded Core Lightning payments pending (#4345)
What changed, and why it matters
This commit changes how LNbits interprets a missing Core Lightning payment record. Previously, if no payment record existed, LNbits marked the payment as failed. Now it marks it as still pending, because a payment that is currently being sent may not have written its first record yet. The main risk is that a payment could appear stuck or be retried incorrectly, potentially leading to duplicate sends or accounting confusion, but the change is a small logic fix rather than an obvious critical vulnerability.
Review how LNbits handles pending payments to ensure it does not retry or double-spend while a payment is genuinely in flight. Verify that PaymentPendingStatus has appropriate timeouts and that callers do not treat pending as a failure. Consider adding tests for the race condition between pay RPC start and listpays polling.
Security signals we found
Change in payment state machine: empty result now treated as pending rather than failed
Potential race condition between payment initiation and status polling
Risk of duplicate payment attempts if pending status leads to retries
No input validation or authorization changes present in diff
Evidence from the diff
In lnbits/wallets/corelightning.py, get_payment_status() now returns PaymentPendingStatus() instead of PaymentFailedStatus() when Core Lightning’s listpays RPC returns an empty ‘pays’ list for a given checking_id/payment_hash. The rationale in the commit message is that a running pay RPC may not have recorded its first attempt yet, so ‘no record’ does not mean ‘failed’. This is a timing/race-condition fix in payment state reconciliation. It does not add authentication, input validation, or access control changes.
Changed components
lnbits/wallets/corelightning.pyCore Lightning wallet backend integrationPayment status reconciliation logicInspect captured patch +2 / −2
### lnbits/wallets/corelightning.py
@@ -327,8 +327,8 @@ async def get_payment_status(self, checking_id: str) -> PaymentStatus:
if "pays" not in r:
return PaymentPendingStatus()
if not r["pays"]:
- # no payment with this payment_hash is found
- return PaymentFailedStatus()
+ # A running pay RPC may not have recorded its first attempt yet.
+ return PaymentPendingStatus()
payment_resp = r["pays"][-1]
Why this scored 44/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.