|
|
@ -8,6 +8,7 @@ |
|
|
|
import InputMask from './InputMask.svelte'; |
|
|
|
import InputMask from './InputMask.svelte'; |
|
|
|
|
|
|
|
|
|
|
|
import payways from './payways.js'; |
|
|
|
import payways from './payways.js'; |
|
|
|
|
|
|
|
|
|
|
|
import QR from './QR.svelte'; |
|
|
|
import QR from './QR.svelte'; |
|
|
|
|
|
|
|
|
|
|
|
import CTC from './CTC.svelte'; |
|
|
|
import CTC from './CTC.svelte'; |
|
|
@ -17,6 +18,7 @@ |
|
|
|
import UTF8 from 'utf-8' |
|
|
|
import UTF8 from 'utf-8' |
|
|
|
|
|
|
|
|
|
|
|
import PayFlow from './PayFlow.svelte'; |
|
|
|
import PayFlow from './PayFlow.svelte'; |
|
|
|
|
|
|
|
import { ecEncrypt } from './ecies.js'; |
|
|
|
|
|
|
|
|
|
|
|
let payway = payways[0]; |
|
|
|
let payway = payways[0]; |
|
|
|
|
|
|
|
|
|
|
@ -28,8 +30,12 @@ |
|
|
|
let inputId; |
|
|
|
let inputId; |
|
|
|
let amountMask; |
|
|
|
let amountMask; |
|
|
|
let realAmount; |
|
|
|
let realAmount; |
|
|
|
|
|
|
|
let extAccount; |
|
|
|
|
|
|
|
let briefAccount; |
|
|
|
|
|
|
|
let encrypt = false; |
|
|
|
|
|
|
|
|
|
|
|
$: inputId = payway.iid||payway.id; |
|
|
|
$: inputId = payway.iid||payway.id; |
|
|
|
|
|
|
|
$: accountReady = accountComplete && accounts[inputId] |
|
|
|
$: amountMask = { |
|
|
|
$: amountMask = { |
|
|
|
mask: Number, scale:2, |
|
|
|
mask: Number, scale:2, |
|
|
|
min: payway.min, max:payway.max, |
|
|
|
min: payway.min, max:payway.max, |
|
|
@ -40,6 +46,10 @@ |
|
|
|
$: realAmount = amounts[payway.id] && ( |
|
|
|
$: realAmount = amounts[payway.id] && ( |
|
|
|
Math.max(Math.min(amounts[payway.id], payway.max),payway.min)) |
|
|
|
Math.max(Math.min(amounts[payway.id], payway.max),payway.min)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$: extAccount = accountReady ? (encrypt? "0g" + ecEncrypt(accounts[inputId].padEnd(8)): accounts[inputId]):""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$: briefAccount = extAccount ? (encrypt ? extAccount.slice(0,28)+"…" : extAccount):"" |
|
|
|
|
|
|
|
|
|
|
|
function genAutoMemo(payway,account,amount) { |
|
|
|
function genAutoMemo(payway,account,amount) { |
|
|
|
if (!account) |
|
|
|
if (!account) |
|
|
|
return "...automatic"; |
|
|
|
return "...automatic"; |
|
|
@ -52,16 +62,12 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let autoMemo; |
|
|
|
let autoMemo; |
|
|
|
$: autoMemo = genAutoMemo(payway, |
|
|
|
$: autoMemo = genAutoMemo(payway, briefAccount, realAmount) |
|
|
|
accountComplete && accounts[inputId], |
|
|
|
|
|
|
|
realAmount) |
|
|
|
|
|
|
|
let lightningAddress; |
|
|
|
let lightningAddress; |
|
|
|
$: lightningAddress = accountComplete ? |
|
|
|
$: lightningAddress = accountComplete ? genAddress(payway, extAccount, realAmount):"" |
|
|
|
genAddress(payway, accounts[inputId], realAmount):"" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function lnurlEncode(url) { |
|
|
|
function lnurlEncode(url) { |
|
|
|
return bech32.encode("LNURL", |
|
|
|
return bech32.encode("LNURL", bech32.toWords(UTF8.setBytesFromString(url)),2048) |
|
|
|
bech32.toWords(UTF8.setBytesFromString(url)),2048) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function toHexString(byteArray) { |
|
|
|
function toHexString(byteArray) { |
|
|
@ -69,6 +75,7 @@ |
|
|
|
return ('0' + (byte & 0xFF).toString(16)).slice(-2); |
|
|
|
return ('0' + (byte & 0xFF).toString(16)).slice(-2); |
|
|
|
}).join('') |
|
|
|
}).join('') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function genAddress(payway,account,amount) { |
|
|
|
function genAddress(payway,account,amount) { |
|
|
|
if (!account || !payway) |
|
|
|
if (!account || !payway) |
|
|
|
return "" |
|
|
|
return "" |
|
|
@ -80,11 +87,12 @@ |
|
|
|
return prefix + account + "@" + payway.id + ".lnurl-pay.me" |
|
|
|
return prefix + account + "@" + payway.id + ".lnurl-pay.me" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function genLNURL(payway,account,amount,memo) { |
|
|
|
function genLNURL(payway,account,amount,memo,isEncrypted) { |
|
|
|
let params = new URLSearchParams(); |
|
|
|
let params = new URLSearchParams(); |
|
|
|
params.set("mtg","pay"); |
|
|
|
params.set("mtg","pay"); |
|
|
|
params.set("p",payway.id); |
|
|
|
params.set("p",payway.id); |
|
|
|
params.set("acc",toHexString(UTF8.setBytesFromString(account))) |
|
|
|
// don't hex-encode bech32-encoded account |
|
|
|
|
|
|
|
params.set("acc",isEncrypted? account: toHexString(UTF8.setBytesFromString(account))) |
|
|
|
params.set("v","1") |
|
|
|
params.set("v","1") |
|
|
|
if (amount) { |
|
|
|
if (amount) { |
|
|
|
params.set(payway.currency.toLowerCase(),amount) |
|
|
|
params.set(payway.currency.toLowerCase(),amount) |
|
|
@ -95,6 +103,7 @@ |
|
|
|
return lnurlEncode("https://lnurl-pay.me/pay?"+params.toString()).toUpperCase() |
|
|
|
return lnurlEncode("https://lnurl-pay.me/pay?"+params.toString()).toUpperCase() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let accounts = {}; |
|
|
|
let accounts = {}; |
|
|
|
let amounts = {}; |
|
|
|
let amounts = {}; |
|
|
|
let memo; |
|
|
|
let memo; |
|
|
@ -102,7 +111,7 @@ |
|
|
|
let lnurl; |
|
|
|
let lnurl; |
|
|
|
|
|
|
|
|
|
|
|
$: lnurl = accountComplete ? |
|
|
|
$: lnurl = accountComplete ? |
|
|
|
genLNURL(payway, accounts[inputId], realAmount, memo) : ""; |
|
|
|
genLNURL(payway, extAccount, realAmount, memo, encrypt) : ""; |
|
|
|
|
|
|
|
|
|
|
|
const curr = { |
|
|
|
const curr = { |
|
|
|
"UAH":"₴", |
|
|
|
"UAH":"₴", |
|
|
@ -138,6 +147,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
{#key payway} |
|
|
|
{#key payway} |
|
|
|
<label class="form-label mb-3">{payway.acc} |
|
|
|
<label class="form-label mb-3">{payway.acc} |
|
|
|
|
|
|
|
<div class="input-group"> |
|
|
|
<InputMask |
|
|
|
<InputMask |
|
|
|
unmask |
|
|
|
unmask |
|
|
|
bind:value={accounts[inputId]} |
|
|
|
bind:value={accounts[inputId]} |
|
|
@ -147,6 +157,16 @@ |
|
|
|
inputmode={payway.inputmode||"numeric"} |
|
|
|
inputmode={payway.inputmode||"numeric"} |
|
|
|
placeholder={payway.placeholder} |
|
|
|
placeholder={payway.placeholder} |
|
|
|
class="form-control"/> |
|
|
|
class="form-control"/> |
|
|
|
|
|
|
|
<span class="input-group-text"> |
|
|
|
|
|
|
|
<div class="form-check-inline form-check input-group-prepend"> |
|
|
|
|
|
|
|
<input class="form-check-input" type="checkbox" id="cbEncrypt" |
|
|
|
|
|
|
|
bind:checked={encrypt}> |
|
|
|
|
|
|
|
<label class="form-check-label" for="cbEncrypt"> |
|
|
|
|
|
|
|
Encrypt |
|
|
|
|
|
|
|
</label> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</div> |
|
|
|
</label> |
|
|
|
</label> |
|
|
|
<label class="form-label mb-3"> |
|
|
|
<label class="form-label mb-3"> |
|
|
|
Amount: {payway.currency} {payway.min} – {payway.max} |
|
|
|
Amount: {payway.currency} {payway.min} – {payway.max} |
|
|
@ -243,7 +263,6 @@ |
|
|
|
</CTC> |
|
|
|
</CTC> |
|
|
|
{/if} |
|
|
|
{/if} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</SiteCard> |
|
|
|
</SiteCard> |
|
|
|
</SiteDeck> |
|
|
|
</SiteDeck> |
|
|
|
|
|
|
|
|
|
|
|