fix: REST contract implementation between lnbits sparkL2 wallet and sparkL2 sidecar (#3952)
What changed, and why it matters
This commit fixes a bug in LNbits' SparkL2 wallet where, after making a payment, the system would use the payment hash as the internal tracking ID if the response from the sidecar service did not provide one. The change makes the system rely only on the sidecar's returned tracking ID. This could prevent bookkeeping mismatches or duplicate/confused payment records, but the commit itself does not describe a security vulnerability.
Review whether any existing SparkL2 payments were tracked using payment_hash instead of the sidecar's checking_id, and reconcile wallet state if needed. Ensure the SparkL2 sidecar always returns a checking_id in its /v1/payments response. Consider adding a regression test for missing checking_id behavior.
Security signals we found
State inconsistency between wallet and sidecar due to fallback identifier
Potential for duplicate or mis-tracked payments if checking_id is not authoritative
Fix aligns REST contract by trusting only the sidecar's returned identifier
Evidence from the diff
In lnbits/wallets/sparkl2.py, the checking_id assignment after a payment request was changed from payment_hash or res.get("checking_id") to res.get("checking_id"). Previously, if the SparkL2 sidecar returned a response without a checking_id, the code would fall back to using the payment_hash as the local checking ID. This fallback could cause the LNbits wallet state and the sidecar’s actual payment state to diverge, potentially leading to incorrect payment status tracking, failed reconciliation, or duplicate payment attempts. The patch enforces that the sidecar must provide the canonical checking ID.
Changed components
lnbits/wallets/sparkl2.pySparkL2Wallet.pay_invoice() methodInspect captured patch +1 / −1
diff --git a/lnbits/wallets/sparkl2.py b/lnbits/wallets/sparkl2.py
index cd863b6..66c33d3 100644
--- a/lnbits/wallets/sparkl2.py
+++ b/lnbits/wallets/sparkl2.py
@@ -159,7 +159,7 @@ class SparkL2Wallet(Wallet):
"payment_hash": payment_hash,
}
res = await self._request("POST", "/v1/payments", payload)
- checking_id = payment_hash or res.get("checking_id")
+ checking_id = res.get("checking_id")
if not checking_id:
return PaymentResponse(
ok=False,
Why this scored 31/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.