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) <noreply@anthropic.com>
This commit is contained in:
parent
e28865abda
commit
93bddbfee9
1 changed files with 19 additions and 5 deletions
|
|
@ -22,13 +22,27 @@ import { QrCode, ExternalLink } from 'lucide-vue-next'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const isElectron = typeof window !== 'undefined' && window.electronAPI !== undefined
|
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)
|
// Build nprofile for Lightning.Pub (pubkey + relay hint)
|
||||||
const lpNprofile = computed(() => {
|
const lpNprofile = computed(() => {
|
||||||
const pubkey = import.meta.env.VITE_LIGHTNING_PUB_PUBKEY
|
if (!lpPubkey.value) return ''
|
||||||
if (!pubkey) return ''
|
const relays = relayUrl.value ? [relayUrl.value.replace('ws://', 'wss://')] : []
|
||||||
const relayUrl = import.meta.env.VITE_RELAY_URL
|
return nip19.nprofileEncode({ pubkey: lpPubkey.value, relays })
|
||||||
const relays = relayUrl ? [relayUrl.replace('ws://', 'wss://')] : []
|
|
||||||
return nip19.nprofileEncode({ pubkey, relays })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Deep link URL: opens ShockWallet with this ATM's Lightning.Pub pre-filled
|
// Deep link URL: opens ShockWallet with this ATM's Lightning.Pub pre-filled
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue