From 0d61244ad470a60b1128cc7c3e29bce305d5edaa Mon Sep 17 00:00:00 2001 From: Anton Kovalenko Date: Sat, 8 Jan 2022 23:05:23 +0300 Subject: [PATCH] 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 --- src/App.svelte | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 1560d70..bb70d0a 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -84,7 +84,11 @@ amount.toFixed(2))+payway.currency.toLowerCase()+"-"):"" if (account[0]=='+') 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) { @@ -100,7 +104,8 @@ if (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() }