From 7ba11614e74e652021df1e8de71cdbedceb57590 Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 19 Mar 2026 12:46:03 +0400 Subject: [PATCH] fix: qr base64 > qr uri --- apps/pay/src/freedom.ts | 14 ++++++++++++-- apps/pay/src/routes.ts | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/pay/src/freedom.ts b/apps/pay/src/freedom.ts index 80ac72f..1a0e693 100644 --- a/apps/pay/src/freedom.ts +++ b/apps/pay/src/freedom.ts @@ -25,8 +25,18 @@ export async function getAddressInfoBulk(addresses: string[]): Promise { + const url = `${API}/invoice/qr/${encodeURIComponent(text)}`; + try { + const res = await fetch(url); + if (!res.ok) return url; + const buf = await res.arrayBuffer(); + const type = res.headers.get("content-type") || "image/png"; + const b64 = Buffer.from(buf).toString("base64"); + return `data:${type};base64,${b64}`; + } catch { + return url; + } } export async function getAvailableCoins(): Promise { diff --git a/apps/pay/src/routes.ts b/apps/pay/src/routes.ts index 952ccf3..2f154d8 100644 --- a/apps/pay/src/routes.ts +++ b/apps/pay/src/routes.ts @@ -1,7 +1,7 @@ import { Elysia, t } from "elysia"; import sql from "./db"; import { derive } from "./address"; -import { getExchangeRates, getAvailableCoins, getQrUrl } from "./freedom"; +import { getExchangeRates, getAvailableCoins, fetchQrBase64 } from "./freedom"; import { PLANS, COINS } from "./plans"; import { watchPayment } from "./monitor"; @@ -121,7 +121,7 @@ export const routes = new Elysia() status: payment.status, expires_at: payment.expires_at, txs: [], - qr_url: getQrUrl(uri), + qr_url: await fetchQrBase64(uri), coin_label: coinInfo.label, coin_ticker: coinInfo.ticker, }; @@ -170,7 +170,7 @@ export const routes = new Elysia() expires_at: payment.expires_at, paid_at: payment.paid_at, txs: txs.map((t: any) => ({ txid: t.txid, amount: t.amount, confirmed: t.confirmed, detected_at: t.detected_at })), - qr_url: getQrUrl(uri), + qr_url: await fetchQrBase64(uri), coin_label: coinInfo?.label, coin_ticker: coinInfo?.ticker, };