From 18f32a14bf7ff71cb0689a5db03210548ac3bf7a Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Fri, 24 Jul 2026 17:32:40 +0700 Subject: [PATCH] Gate built-in Cashu mint wallet to native-only (browser CORS reality) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browsers block most Cashu mints (no CORS headers), so minting/melting fails unreliably in-browser — and the failed fetches spam the console. Rather than ship a broken browser feature: - CashuWalletCard: in a browser, render a clear "built-in ecash runs in the app" notice pointing users to zaps (NWC/WebLN/Lightning address) which work fine in-browser; full mint wallet renders only on native (Capacitor) - useCashu: skip coco/IndexedDB/mint init entirely in the browser (isNativePlatform guard) — stops the recurring "Failed to fetch mint" console errors at the source - Zaps/tips (the app's real money flow) are unaffected — they never touch a Cashu mint Native builds get the full wallet with minibits working directly (no CORS jail), per the earlier platform-aware work. Co-authored-by: shakespeare.diy --- src/components/wallet/CashuWalletCard.tsx | 59 +++++++++++++++++++++++ src/hooks/wallet/useCashu.ts | 7 ++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/components/wallet/CashuWalletCard.tsx b/src/components/wallet/CashuWalletCard.tsx index b97cb84..01869c6 100644 --- a/src/components/wallet/CashuWalletCard.tsx +++ b/src/components/wallet/CashuWalletCard.tsx @@ -39,8 +39,67 @@ import { import { useToast } from '@/hooks/useToast'; import { QRScannerModal } from '@/components/wallet/QRScannerModal'; import { MintPrivacyManager } from '@/components/wallet/MintPrivacyManager'; +import { isNativePlatform } from '@/lib/platform'; +import { Smartphone } from 'lucide-react'; +/** + * The built-in Cashu (ecash) mint wallet only works where there's no browser + * CORS jail — i.e. in the native app. In a plain web browser most mints block + * requests (no Access-Control-Allow-Origin), so minting/melting fails. Rather + * than ship a browser feature that unreliably errors, we gate the full wallet + * to native and, in the browser, explain how to transact (zaps via a connected + * Lightning wallet, or use the native app). + * + * Zaps/tips — the app's actual money flow — keep working in the browser via + * NWC / WebLN / Lightning address, none of which touch a Cashu mint. + */ export function CashuWalletCard() { + if (!isNativePlatform()) { + return ; + } + return ; +} + +function CashuWalletBrowserNotice() { + return ( + + + + + Built-in Ecash Wallet + + + The built-in Cashu wallet runs in the SkateSpots app + + + +
+ +
+

Open SkateSpots in the app to use ecash

+

+ Web browsers block most Cashu mints for security reasons, so the built-in ecash + wallet is available in the native app. Everything else — sending and receiving + zaps — works right here in your browser. +

+
+
+ +
+

+ Zap & tip in the browser +

+

+ Connect a Lightning wallet below (Nostr Wallet Connect or a browser extension like + Alby) to zap spots, events, coaches, and crews. No Cashu mint required. +

+
+
+
+ ); +} + +function CashuWalletCardNative() { const { coco, repositories, diff --git a/src/hooks/wallet/useCashu.ts b/src/hooks/wallet/useCashu.ts index ea4fb1f..408f45a 100644 --- a/src/hooks/wallet/useCashu.ts +++ b/src/hooks/wallet/useCashu.ts @@ -97,7 +97,12 @@ export function useCashu(): UseCashuReturn { // Initialize the coco manager const initializeCocoManager = useCallback(async () => { if (isInitialized || isLoading) return; - + + // The Cashu mint wallet is native-only: browsers block most mints via CORS, + // so there's no point spinning up coco / IndexedDB / mint probing (and the + // failed mint fetches spam the console). Skip init entirely in the browser. + if (!isNativePlatform()) return; + setIsLoading(true); setError(null);