Fix lnaddr attach fails if minSendable > 1000 (#2138)

* Fix lnaddr attach fails if minSendable > 1000

* Don't fetch lnAddr options twice for test invoice
This commit is contained in:
ekzyis 2025-04-26 18:15:47 +02:00 committed by GitHub
parent 4ad64d658f
commit 97317d4c0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@ import { assertContentTypeJson, assertResponseOk } from '@/lib/url'
export * from '@/wallets/lightning-address'
export const testCreateInvoice = async ({ address }, { signal }) => {
return await createInvoice({ msats: 1000 }, { address }, { signal })
return await createInvoice({ msats: undefined }, { address }, { signal })
}
export const createInvoice = async (
@ -14,10 +14,14 @@ export const createInvoice = async (
{ address },
{ signal }
) => {
const { callback, commentAllowed } = await lnAddrOptions(address, { signal })
const { min, callback, commentAllowed } = await lnAddrOptions(address, { signal })
const callbackUrl = new URL(callback)
// most lnurl providers suck nards so we have to floor to nearest sat
if (!msats) {
// use min sendable amount by default
msats = 1_000 * min
}
msats = msatsSatsFloor(msats)
callbackUrl.searchParams.append('amount', msats)