From 93bddbfee9500b5d7bedf8d035754724f516a292 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Wed, 1 Apr 2026 16:25:16 -0400 Subject: [PATCH] fix(ui): load LP nprofile from runtime config instead of build-time env VITE_ env vars are baked in at build time and empty in the Nix build. Now reads lightningPubPubkey and relayUrl from Electron's getConfig() at runtime, with dev fallback to import.meta.env. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/machine/src/views/SupportView.vue | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/machine/src/views/SupportView.vue b/apps/machine/src/views/SupportView.vue index adec484..93803e5 100644 --- a/apps/machine/src/views/SupportView.vue +++ b/apps/machine/src/views/SupportView.vue @@ -22,13 +22,27 @@ import { QrCode, ExternalLink } from 'lucide-vue-next' const router = useRouter() const isElectron = typeof window !== 'undefined' && window.electronAPI !== undefined +// Lightning.Pub config loaded at runtime from Electron main process +const lpPubkey = ref('') +const relayUrl = ref('') + +onMounted(async () => { + if (isElectron && window.electronAPI) { + const config = await window.electronAPI.getConfig() + lpPubkey.value = config.lightningPubPubkey || '' + relayUrl.value = config.relayUrl || '' + } else { + // Dev fallback: use Vite env vars + lpPubkey.value = import.meta.env.VITE_LIGHTNING_PUB_PUBKEY || '' + relayUrl.value = import.meta.env.VITE_RELAY_URL || '' + } +}) + // Build nprofile for Lightning.Pub (pubkey + relay hint) const lpNprofile = computed(() => { - const pubkey = import.meta.env.VITE_LIGHTNING_PUB_PUBKEY - if (!pubkey) return '' - const relayUrl = import.meta.env.VITE_RELAY_URL - const relays = relayUrl ? [relayUrl.replace('ws://', 'wss://')] : [] - return nip19.nprofileEncode({ pubkey, relays }) + if (!lpPubkey.value) return '' + const relays = relayUrl.value ? [relayUrl.value.replace('ws://', 'wss://')] : [] + return nip19.nprofileEncode({ pubkey: lpPubkey.value, relays }) }) // Deep link URL: opens ShockWallet with this ATM's Lightning.Pub pre-filled