From 92176bea83e814683a67801377c8d5d01320b87a Mon Sep 17 00:00:00 2001 From: padreug Date: Thu, 16 Oct 2025 00:53:06 +0200 Subject: [PATCH] add env variable for lightning domain leveraging redirect capability --- .env.example | 6 ++++++ src/lib/config/index.ts | 4 +++- src/modules/wallet/services/WalletService.ts | 9 +++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index d56e717..ea5e8d1 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,12 @@ VITE_ADMIN_PUBKEYS=["your-admin-pubkey-here"] VITE_LNBITS_BASE_URL=http://localhost:5000 VITE_API_KEY=your-api-key-here +# Lightning Address Domain (optional) +# Override the domain used for Lightning Addresses +# If not set, domain will be extracted from VITE_LNBITS_BASE_URL +# Example: mydomain.com will show addresses as username@mydomain.com +VITE_LIGHTNING_DOMAIN= + # Push Notifications VITE_VAPID_PUBLIC_KEY=your-vapid-public-key VITE_PUSH_NOTIFICATIONS_ENABLED=true diff --git a/src/lib/config/index.ts b/src/lib/config/index.ts index 713b2f8..43b7203 100644 --- a/src/lib/config/index.ts +++ b/src/lib/config/index.ts @@ -9,6 +9,7 @@ interface NostrConfig { interface ApiConfig { baseUrl: string key: string + lightningDomain?: string // Optional override for Lightning Address domain } interface PushConfig { @@ -56,7 +57,8 @@ export const config: AppConfig = { }, api: { baseUrl: import.meta.env.VITE_LNBITS_BASE_URL || '', - key: import.meta.env.VITE_API_KEY || '' + key: import.meta.env.VITE_API_KEY || '', + lightningDomain: import.meta.env.VITE_LIGHTNING_DOMAIN // Optional override for Lightning Address domain }, push: { vapidPublicKey: import.meta.env.VITE_VAPID_PUBLIC_KEY || '', diff --git a/src/modules/wallet/services/WalletService.ts b/src/modules/wallet/services/WalletService.ts index a47f8a0..a18b625 100644 --- a/src/modules/wallet/services/WalletService.ts +++ b/src/modules/wallet/services/WalletService.ts @@ -148,8 +148,8 @@ export default class WalletService extends BaseService { payLink.lnurl = `${baseUrl}/lnurlp/${payLink.id}` if (payLink.username) { - // Extract domain from base URL - const domain = new URL(baseUrl).hostname + // Use custom Lightning domain if configured, otherwise extract from base URL + const domain = config.api.lightningDomain || new URL(baseUrl).hostname payLink.lnaddress = `${payLink.username}@${domain}` } @@ -310,8 +310,9 @@ export default class WalletService extends BaseService { if (response.ok) { const links = await response.json() const baseUrl = config.api.baseUrl - const domain = new URL(baseUrl).hostname - + // Use custom Lightning domain if configured, otherwise extract from base URL + const domain = config.api.lightningDomain || new URL(baseUrl).hostname + // Add LNURL and Lightning Address to each link this._payLinks.value = links.map((link: PayLink) => ({ ...link,