fix(lndrest): use boolean for allow_self_payment instead of integer (#3700)
What changed, and why it matters
This commit fixes a small data-type bug in LNbits' integration with the LND lightning node. The code was sending the number 1 where LND expects a true/false boolean for the 'allow_self_payment' option. Depending on how strictly LND validates the request, this could cause self-payments to be rejected or handled incorrectly, potentially breaking a feature or creating inconsistent payment behavior.
Treat as a routine bug fix. Review whether the integer value caused any unexpected LND behavior (rejected self-payments, fallback logic, or silently disabled self-payments) in affected deployments. No urgent security response is indicated by the diff alone.
Security signals we found
API request field type mismatch corrected
Payment-routing option corrected from integer to boolean
Potential functional bug in self-payment handling
Evidence from the diff
In lnbits/wallets/lndrest.py, the LND REST wallet’s send_payment method builds a JSON request for LND’s router SendPaymentV2 endpoint. The field allow_self_payment was being set to the integer 1 instead of the boolean True. LND’s protobuf-to-JSON gateway typically expects bool fields as JSON true/false. The patch changes the value to Python True so the serialized JSON becomes true. This is a correctness fix; the practical security impact is limited and depends on whether LND silently coerced 1 to true, rejected the request, or behaved unexpectedly.
Changed components
lnbits/wallets/lndrest.pyLND REST wallet payment senderInspect captured patch +1 / −1
diff --git a/lnbits/wallets/lndrest.py b/lnbits/wallets/lndrest.py
index 861448d..da72a61 100644
--- a/lnbits/wallets/lndrest.py
+++ b/lnbits/wallets/lndrest.py
@@ -178,7 +178,7 @@ class LndRestWallet(Wallet):
"no_inflight_updates": True,
}
if settings.lnd_rest_allow_self_payment:
- req["allow_self_payment"] = 1
+ req["allow_self_payment"] = True
try:
r = await self.client.post(
Why this scored 29/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.