blob: 95d0a8b61bcf0d1c1866c483bc59c16d4c3df555 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// import bolt11 from 'bolt11';
import validate from 'bitcoin-address-validation';
import bip21 from 'bip21';
import { get } from '$lib/utils';
import { goto } from '$app/navigation';
let debounce;
export default async (t) => {
if (!t) return;
console.log('parsing');
// lightning
if (t.startsWith('ln')) {
goto(`/send/lightning/${t}`);
}
// bitcoin
if (validate(t)) {
console.log('bitcoin');
goto(`/send/bitcoin/${t}`);
}
// ln address
if (t.includes('@') && t.includes('.')) {
console.log('ln address');
let [name, domain] = t.split('@');
try {
clearTimeout(debounce);
await new Promise((r) => (debounce = setTimeout(r, 1500)));
let lnurl = await get(`/encode?domain=${domain}&name=${name}`);
console.log('lnurl', lnurl);
} catch (e) {}
}
// user
console.log('username');
};
|