fix: qr base64 > qr uri

This commit is contained in:
2026-03-19 12:46:03 +04:00
parent ae9c18b771
commit 7ba11614e7
2 changed files with 15 additions and 5 deletions
+12 -2
View File
@@ -25,8 +25,18 @@ export async function getAddressInfoBulk(addresses: string[]): Promise<Record<st
return res.json();
}
export function getQrUrl(text: string): string {
return `${API}/invoice/qr/${encodeURIComponent(text)}`;
export async function fetchQrBase64(text: string): Promise<string> {
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<string[]> {