diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/utils.js | 14 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/+page.svelte | 9 | ||||
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.server.js | 4 | ||||
| -rw-r--r-- | src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js | 8 |
4 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js index 9dbdc2ab..738413bf 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -287,3 +287,17 @@ export let closest = (a, n) => a.reduce((prev, curr) => Math.abs(curr - n) < Math.abs(prev - n) ? curr : prev ); + +export let isLiquid = (text) => + text.startsWith("Az") || + text.startsWith("lq1") || + text.startsWith("VJL") || + text.startsWith("VT") || + text.startsWith("XR") || + text.startsWith("XC") || + ((text.startsWith("H") || text.startsWith("G") || text.startsWith("Q")) && + text.length === 34) || + (text.startsWith("ert1q") && text.length === 43) || + (text.startsWith("ex1q") && text.length === 42) || + text.startsWith("el1qq") || + text.startsWith("lq1qq"); diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 1acd0d3d..e07d630a 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -16,7 +16,7 @@ import Avatar from "$comp/Avatar.svelte"; import Icon from "$comp/Icon.svelte"; import { format } from "date-fns"; - import { PUBLIC_EXPLORER as expl } from "$env/static/public"; + import { PUBLIC_EXPLORER, PUBLIC_LIQUID_EXPLORER } from "$env/static/public"; export let data; let { user, payment: p } = data; @@ -37,6 +37,11 @@ } = p; let a = Math.abs(amount); + let expl = { + bitcoin: PUBLIC_EXPLORER, + liquid: PUBLIC_LIQUID_EXPLORER, + }[type]; + let print = async () => { await post(`/payment/${id}/print`, { id }); success("Printing!"); @@ -157,7 +162,7 @@ <span class="text-lg text-secondary">Txid</span> <div class="flex"> <div> - <a + <a href={`${expl}/tx/${txid}${vout ? "#vout=" + vout : ""}`} target="_blank" rel="noreferrer">{txid}</a diff --git a/src/routes/(app)/send/[...text]/+page.server.js b/src/routes/(app)/send/[...text]/+page.server.js index 3e6b7c13..73a44512 100644 --- a/src/routes/(app)/send/[...text]/+page.server.js +++ b/src/routes/(app)/send/[...text]/+page.server.js @@ -1,6 +1,6 @@ import { validate } from "bitcoin-address-validation"; import bip21 from "bip21"; -import { auth, get, post } from "$lib/utils"; +import { auth, get, isLiquid, post } from "$lib/utils"; import { fail, redirect } from "@sveltejs/kit"; import { PUBLIC_DOMAIN } from "$env/static/public"; @@ -46,7 +46,7 @@ let parse = async (t, host) => { } // bitcoin - if (validate(t)) { + if (validate(t) || isLiquid(t)) { try { ({ id, user } = await get(`/invoice/${t}`)); } catch (e) { diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js index 86f9fde8..6f735f32 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js @@ -5,13 +5,7 @@ let seen = {}; export async function load({ params: { address, amount, feeRate }, cookies }) { try { - let fees = await fetch( - `https://mempool.space/api/v1/fees/recommended` - ).then((r) => r.json()); - - if (!feeRate) feeRate = fees.halfHourFee; - - let { fee, ourfee, hex } = await post( + let { fee, fees, ourfee, hex } = await post( "/bitcoin/fee", { address, amount, feeRate }, auth(cookies) |
