Support .onion for phoenixd (#1975)

* fix #1964 support .onion urls like lnbits does

* fix lint: const hostname

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
This commit is contained in:
Scroogey-SN 2025-03-18 20:39:53 +00:00 committed by GitHub
parent b7dfef41c0
commit e31f8e9c69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
import { fetchWithTimeout } from '@/lib/fetch'
import { msatsToSats } from '@/lib/format'
import { getAgent } from '@/lib/proxy'
import { assertContentTypeJson, assertResponseOk } from '@/lib/url'
export * from '@/wallets/phoenixd'
@ -27,9 +28,13 @@ export async function createInvoice (
body.append('description', description)
body.append('amountSat', msatsToSats(msats))
const res = await fetchWithTimeout(url + path, {
const hostname = url.replace(/^https?:\/\//, '').replace(/\/+$/, '')
const agent = getAgent({ hostname })
const res = await fetchWithTimeout(`${agent.protocol}//${hostname}${path}`, {
method: 'POST',
headers,
agent,
body,
signal
})