nip57: lud16 must take precedence over lud06

This commit is contained in:
雪猫
2025-10-12 15:31:39 +09:00
committed by fiatjaf_
parent bc1294e4e6
commit e8927d78e6

View File

@@ -18,13 +18,13 @@ export async function getZapEndpoint(metadata: Event): Promise<null | string> {
try { try {
let lnurl: string = '' let lnurl: string = ''
let { lud06, lud16 } = JSON.parse(metadata.content) let { lud06, lud16 } = JSON.parse(metadata.content)
if (lud06) { if (lud16) {
let [name, domain] = lud16.split('@')
lnurl = new URL(`/.well-known/lnurlp/${name}`, `https://${domain}`).toString()
} else if (lud06) {
let { words } = bech32.decode(lud06, 1000) let { words } = bech32.decode(lud06, 1000)
let data = bech32.fromWords(words) let data = bech32.fromWords(words)
lnurl = utf8Decoder.decode(data) lnurl = utf8Decoder.decode(data)
} else if (lud16) {
let [name, domain] = lud16.split('@')
lnurl = new URL(`/.well-known/lnurlp/${name}`, `https://${domain}`).toString()
} else { } else {
return null return null
} }