feat: lnd_rest allow self payments (#2760)

* Update lndrest.py

- added the ability to receive self payments on the node

[issue] You have to enable circular payment on lnd.conf. Note that lnd.conf doesn't allow allow_self_payment parameter, that is why is necessary to define that on transaction.

* feat: add LND rest `"allow_self_payment"` option

---------

Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
jjmmbb 2024-11-26 09:32:44 -03:00 committed by GitHub
parent af568d0f31
commit f97f27121a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 4 deletions

View file

@ -323,6 +323,7 @@ class LndRestFundingSource(LNbitsSettings):
lnd_rest_macaroon: Optional[str] = Field(default=None)
lnd_rest_macaroon_encrypted: Optional[str] = Field(default=None)
lnd_rest_route_hints: bool = Field(default=True)
lnd_rest_allow_self_payment: bool = Field(default=False)
lnd_cert: Optional[str] = Field(default=None)
lnd_admin_macaroon: Optional[str] = Field(default=None)
lnd_invoice_macaroon: Optional[str] = Field(default=None)

File diff suppressed because one or more lines are too long

View file

@ -64,7 +64,8 @@ window.app.component('lnbits-funding-sources', {
lnd_rest_cert: 'Certificate',
lnd_rest_macaroon: 'Macaroon',
lnd_rest_macaroon_encrypted: 'Encrypted Macaroon',
lnd_rest_route_hints: 'Enable Route Hints'
lnd_rest_route_hints: 'Enable Route Hints',
lnd_rest_allow_self_payment: 'Allow Self Payment'
}
],
[

View file

@ -2,7 +2,7 @@ import asyncio
import base64
import hashlib
import json
from typing import AsyncGenerator, Dict, Optional
from typing import Any, AsyncGenerator, Dict, Optional
import httpx
from loguru import logger
@ -168,9 +168,15 @@ class LndRestWallet(Wallet):
lnrpc_fee_limit["fixed_msat"] = f"{fee_limit_msat}"
try:
json_: dict[str, Any] = {
"payment_request": bolt11,
"fee_limit": lnrpc_fee_limit,
}
if settings.lnd_rest_allow_self_payment:
json_["allow_self_payment"] = 1
r = await self.client.post(
url="/v1/channels/transactions",
json={"payment_request": bolt11, "fee_limit": lnrpc_fee_limit},
json=json_,
timeout=None,
)
r.raise_for_status()