Become domain-agnostic, with .onion-specific address generation

1) use window.location instead of hardcoded lnurl-pay.me
2) don't use subdomains for address creation on .onion
This commit is contained in:
Anton Kovalenko 2022-01-08 23:05:23 +03:00
parent 5e69a9bedf
commit 0d61244ad4

View File

@ -84,7 +84,11 @@
amount.toFixed(2))+payway.currency.toLowerCase()+"-"):"" amount.toFixed(2))+payway.currency.toLowerCase()+"-"):""
if (account[0]=='+') if (account[0]=='+')
account=account.slice(1) account=account.slice(1)
return prefix + account + "@" + payway.id + ".lnurl-pay.me" if (window.location.hostname.endsWith(".onion")) {
return prefix + account + "." + payway.id + "@" + window.location.hostname
} else {
return prefix + account + "@" + payway.id + "." + window.location.hostname
}
} }
function genLNURL(payway,account,amount,memo,isEncrypted) { function genLNURL(payway,account,amount,memo,isEncrypted) {
@ -100,7 +104,8 @@
if (memo) { if (memo) {
params.set("m",toHexString(UTF8.setBytesFromString(memo))) params.set("m",toHexString(UTF8.setBytesFromString(memo)))
} }
return lnurlEncode("https://lnurl-pay.me/pay?"+params.toString()).toUpperCase() const me = window.location.protocol + "//" + window.location.host
return lnurlEncode(me + "/pay?" + params.toString()).toUpperCase()
} }