From 187a38a600876d156e543e4c0273916c354422fd Mon Sep 17 00:00:00 2001 From: David Klakurka Date: Wed, 5 Nov 2025 22:02:09 -0800 Subject: [PATCH 1/2] Added better cashtab-connect error handling --- react/lib/util/cashtab.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/react/lib/util/cashtab.ts b/react/lib/util/cashtab.ts index 4b8bf40b..f73b2036 100644 --- a/react/lib/util/cashtab.ts +++ b/react/lib/util/cashtab.ts @@ -82,23 +82,30 @@ export const sendXecWithCashtab = async (address: string, amount: string | numbe * @param fallbackUrl - Optional fallback URL if extension is not available */ export const openCashtabPayment = async (bip21Url: string, fallbackUrl?: string): Promise => { + const webUrl = fallbackUrl || `https://cashtab.com/#/send?bip21=${bip21Url}`; + try { const isAvailable = await getCashtabProviderStatus(); if (isAvailable) { - cashtab.sendBip21(bip21Url); + await cashtab.sendBip21(bip21Url); } else { - const webUrl = fallbackUrl || `https://cashtab.com/#/send?bip21=${bip21Url}`; window.open(webUrl, '_blank'); } } catch (error) { if (error instanceof CashtabAddressDeniedError) { - // User rejected the transaction - do nothing for now - // This case is handled here in case we want to add specific behavior in the future + // User rejected the transaction - do nothing return; } - - const webUrl = fallbackUrl || `https://cashtab.com/#/send?bip21=${bip21Url}`; + if ( + error instanceof CashtabExtensionUnavailableError || + error instanceof CashtabTimeoutError + ) { + // Extension not available or timed out: fallback to web + window.open(webUrl, '_blank'); + return; + } + // Unknown error: still attempt web fallback window.open(webUrl, '_blank'); } }; From 3db6ee6db6f016da05468ca88e6195d580f6f343 Mon Sep 17 00:00:00 2001 From: David Klakurka Date: Wed, 5 Nov 2025 22:22:23 -0800 Subject: [PATCH 2/2] Nit --- react/lib/util/cashtab.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react/lib/util/cashtab.ts b/react/lib/util/cashtab.ts index f73b2036..f4787ea6 100644 --- a/react/lib/util/cashtab.ts +++ b/react/lib/util/cashtab.ts @@ -91,6 +91,7 @@ export const openCashtabPayment = async (bip21Url: string, fallbackUrl?: string) await cashtab.sendBip21(bip21Url); } else { window.open(webUrl, '_blank'); + return; } } catch (error) { if (error instanceof CashtabAddressDeniedError) {