Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MINT_LND_REST_CERT_VERIFY env bool that when set to False allow to skip certificate validation for LND api call #535

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ MINT_LNBITS_KEY=yourkeyasdasdasd
MINT_LND_REST_ENDPOINT=https://127.0.0.1:8086
MINT_LND_REST_CERT="/home/lnd/.lnd/tls.cert"
MINT_LND_REST_MACAROON="/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon"
MINT_LND_REST_CERT_VERIFY=True

# Use with CoreLightningRestWallet
MINT_CORELIGHTNING_REST_URL=https://localhost:3001
Expand Down
1 change: 1 addition & 0 deletions cashu/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class WalletSettings(CashuSettings):
class LndRestFundingSource(MintSettings):
mint_lnd_rest_endpoint: Optional[str] = Field(default=None)
mint_lnd_rest_cert: Optional[str] = Field(default=None)
mint_lnd_rest_cert_verify: bool = Field(default=True)
mint_lnd_rest_macaroon: Optional[str] = Field(default=None)
mint_lnd_rest_admin_macaroon: Optional[str] = Field(default=None)
mint_lnd_rest_invoice_macaroon: Optional[str] = Field(default=None)
Expand Down
12 changes: 12 additions & 0 deletions cashu/lightning/lndrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, unit: Unit = Unit.sat, **kwargs):
self.unit = unit
endpoint = settings.mint_lnd_rest_endpoint
cert = settings.mint_lnd_rest_cert
cert_verify = settings.mint_lnd_rest_cert_verify

macaroon = (
settings.mint_lnd_rest_macaroon
Expand All @@ -54,6 +55,12 @@ def __init__(self, unit: Unit = Unit.sat, **kwargs):
" publicly issued certificate"
)

if not cert_verify:
logger.warning(
"certificate validation will be disabled for lndrest"
)


endpoint = endpoint[:-1] if endpoint.endswith("/") else endpoint
endpoint = (
f"https://{endpoint}" if not endpoint.startswith("http") else endpoint
Expand All @@ -66,6 +73,11 @@ def __init__(self, unit: Unit = Unit.sat, **kwargs):
# even on startup
self.cert = cert or True

# disable cert verify if choosen
if not cert_verify:
self.cert = False


self.auth = {"Grpc-Metadata-macaroon": self.macaroon}
self.client = httpx.AsyncClient(
base_url=self.endpoint, headers=self.auth, verify=self.cert
Expand Down
Loading