Compare commits
2 Commits
c1c010f24c
...
8663e85c5c
Author | SHA1 | Date | |
---|---|---|---|
8663e85c5c | |||
ae70ec80b1 |
109
src/App.svelte
109
src/App.svelte
@ -6,7 +6,7 @@
|
|||||||
import SiteCard from './SiteCard.svelte';
|
import SiteCard from './SiteCard.svelte';
|
||||||
import SiteDeck from './SiteDeck.svelte';
|
import SiteDeck from './SiteDeck.svelte';
|
||||||
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';
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
import PayFlow from './PayFlow.svelte';
|
import PayFlow from './PayFlow.svelte';
|
||||||
|
|
||||||
let payway = payways[0];
|
let payway = payways[0];
|
||||||
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
payway = payways[0];
|
payway = payways[0];
|
||||||
accounts[inputId]=null;
|
accounts[inputId]=null;
|
||||||
@ -55,17 +55,30 @@
|
|||||||
$: autoMemo = genAutoMemo(payway,
|
$: autoMemo = genAutoMemo(payway,
|
||||||
accountComplete && accounts[inputId],
|
accountComplete && accounts[inputId],
|
||||||
realAmount)
|
realAmount)
|
||||||
|
let lightningAddress;
|
||||||
|
$: lightningAddress = accountComplete ?
|
||||||
|
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) {
|
||||||
return Array.from(byteArray, function(byte) {
|
return Array.from(byteArray, function(byte) {
|
||||||
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
|
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
|
||||||
}).join('')
|
}).join('')
|
||||||
}
|
}
|
||||||
|
function genAddress(payway,account,amount) {
|
||||||
|
if (!account || !payway)
|
||||||
|
return ""
|
||||||
|
const prefix = amount?
|
||||||
|
((amount == Math.floor(amount)? ""+amount:
|
||||||
|
amount.toFixed(2))+payway.currency.toLowerCase()+"-"):""
|
||||||
|
if (account[0]=='+')
|
||||||
|
account=account.slice(1)
|
||||||
|
return prefix + account + "@" + payway.id + ".lnurl-pay.me"
|
||||||
|
}
|
||||||
|
|
||||||
function genLNURL(payway,account,amount,memo) {
|
function genLNURL(payway,account,amount,memo) {
|
||||||
let params = new URLSearchParams();
|
let params = new URLSearchParams();
|
||||||
@ -125,7 +138,7 @@
|
|||||||
|
|
||||||
{#key payway}
|
{#key payway}
|
||||||
<label class="form-label mb-3">{payway.acc}
|
<label class="form-label mb-3">{payway.acc}
|
||||||
<InputMask
|
<InputMask
|
||||||
unmask
|
unmask
|
||||||
bind:value={accounts[inputId]}
|
bind:value={accounts[inputId]}
|
||||||
bind:isComplete={accountComplete}
|
bind:isComplete={accountComplete}
|
||||||
@ -163,7 +176,6 @@
|
|||||||
<input bind:value={memo} placeholder="{autoMemo}"
|
<input bind:value={memo} placeholder="{autoMemo}"
|
||||||
class="form-control"/>
|
class="form-control"/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
</SiteCard>
|
</SiteCard>
|
||||||
<SiteCard>
|
<SiteCard>
|
||||||
{#if lnurl}
|
{#if lnurl}
|
||||||
@ -177,45 +189,56 @@
|
|||||||
<div class="form-text mb-2 mt-2">Expecting: {payway.acc.toLowerCase()}</div>
|
<div class="form-text mb-2 mt-2">Expecting: {payway.acc.toLowerCase()}</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="d-flex justify-content-center align-items-stretch m-2"
|
<div class="d-flex justify-content-center align-items-stretch m-2"
|
||||||
class:invisible={!lnurl}>
|
class:invisible={!lnurl}>
|
||||||
<!-- {#key lnurl} -->
|
<!-- {#key lnurl} -->
|
||||||
<a href="lightning:{lnurl}">
|
<a href="lightning:{lnurl}">
|
||||||
<QR value={lnurl} size="{230}" />
|
<QR value={lnurl} size="{230}" />
|
||||||
</a>
|
</a>
|
||||||
<!-- {/key} -->
|
<!-- {/key} -->
|
||||||
</div>
|
</div>
|
||||||
|
<div class="btn-group flex-wrap mt-auto mb-2"
|
||||||
<div class="d-flex justify-content-center align-items-stretch"
|
role="group" class:invisible={!lnurl}>
|
||||||
class:invisible={!lnurl}>
|
<CTC let:id let:action text={lnurl}>
|
||||||
<p class="form-text">You might want to save image and share it
|
<button type="button" class="btn btn-outline-secondary"
|
||||||
as you like. All form data are present in lnurl: don't share what you wanted to hide.</p>
|
id={id} on:click={action}>Copy</button>
|
||||||
</div>
|
</CTC>
|
||||||
|
{#if canShare}
|
||||||
<div class="btn-group flex-wrap mt-auto mb-2"
|
<button type="button" class="btn btn-outline-secondary"
|
||||||
role="group" class:invisible={!lnurl}>
|
on:click={()=>{ navigator.share({text:lnurl})}}>Share
|
||||||
<CTC let:id let:action text={lnurl}>
|
</button>
|
||||||
<button type="button" class="btn btn-outline-secondary"
|
{/if}
|
||||||
id={id} on:click={action}>Copy</button>
|
<Tipped let:id>
|
||||||
</CTC>
|
<a slot="thing" role="button" class="btn btn-outline-secondary"
|
||||||
{#if canShare}
|
href="lightning:{lnurl}" {id}>Pay</a>
|
||||||
<button type="button" class="btn btn-outline-secondary"
|
<div slot="tip">open in your wallet</div>
|
||||||
on:click={()=>{ navigator.share({text:lnurl})}}>Share
|
</Tipped>
|
||||||
</button>
|
|
||||||
{/if}
|
<Tipped let:id>
|
||||||
<Tipped let:id>
|
<button slot="thing" {id} type="button"
|
||||||
<a slot="thing" role="button" class="btn btn-outline-secondary"
|
class="btn btn-outline-secondary"
|
||||||
href="lightning:{lnurl}" {id}>Pay</a>
|
on:click="{()=>getInvoiceFor=lnurl}">
|
||||||
<div slot="tip">open in your wallet</div>
|
Invoice</button>
|
||||||
</Tipped>
|
<div slot="tip">get an invoice for wallets with no lnurl-pay</div>
|
||||||
|
</Tipped>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if lightningAddress}
|
||||||
|
<CTC let:id let:action force text={lightningAddress}}>
|
||||||
|
<div class="input-group mt-3">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text">
|
||||||
|
<a href="https://lightningaddress.com/">Lightning address:</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="user-select-all form-control"
|
||||||
|
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
|
||||||
|
on:click={action} id={id}>{lightningAddress}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CTC>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
<Tipped let:id>
|
|
||||||
<button slot="thing" {id} type="button"
|
|
||||||
class="btn btn-outline-secondary"
|
|
||||||
on:click="{()=>getInvoiceFor=lnurl}">
|
|
||||||
Invoice</button>
|
|
||||||
<div slot="tip">get an invoice for wallets with no lnurl-pay</div>
|
|
||||||
</Tipped>
|
|
||||||
</div>
|
|
||||||
</SiteCard>
|
</SiteCard>
|
||||||
</SiteDeck>
|
</SiteDeck>
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ export default [
|
|||||||
{"name":"💳 🇺🇦 UAH ₴ Visa/MC",
|
{"name":"💳 🇺🇦 UAH ₴ Visa/MC",
|
||||||
"currency":"UAH",
|
"currency":"UAH",
|
||||||
"min":10,
|
"min":10,
|
||||||
"max":5000,
|
"max":20000,
|
||||||
"imask":masks.cc,
|
"imask":masks.cc,
|
||||||
"iid":"cc",
|
"iid":"cc",
|
||||||
"acc":"Card number",
|
"acc":"Card number",
|
||||||
|
Loading…
Reference in New Issue
Block a user