diff --git a/apps/mobile/src/modules/Cashu/qr/ScanCode.tsx b/apps/mobile/src/modules/Cashu/qr/ScanCode.tsx index 1f24d574..a4f2b310 100644 --- a/apps/mobile/src/modules/Cashu/qr/ScanCode.tsx +++ b/apps/mobile/src/modules/Cashu/qr/ScanCode.tsx @@ -18,6 +18,7 @@ const ScanCashuQRCode: React.FC = ({onClose}) => { const {showToast} = useToast(); const handleScannedCode = async ({data}: BarcodeScanningResult) => { + console.log('Scanned data:', data); // Debugging: Log the scanned data if (!data) { showToast({title: 'Invalid QR code', type: 'error'}); return; @@ -25,16 +26,24 @@ const ScanCashuQRCode: React.FC = ({onClose}) => { setScanned(true); setScannedData(data); - if (action === 'send' && data.startsWith('lightning:')) { - const invoice = data.replace('lightning:', ''); - await handlePayInvoice(invoice); - onClose(); - } else if (action === 'receive' && data.startsWith('cashu')) { - await handleGenerateEcash(Number(data.replace('cashu', ''))); - onClose(); + if (data.startsWith('lnbc')) { + // Lightning invoice + if (action === 'send') { + await handlePayInvoice(data); + showToast({title: 'Invoice paid successfully', type: 'success'}); + } else { + showToast({title: 'This is a Lightning invoice. Please select "Pay".', type: 'info'}); + } } else { - showToast({title: 'Invalid QR code', type: 'error'}); + // Assume eCash + if (action === 'receive') { + await handleGenerateEcash(Number(data.replace('cashu', ''))); + showToast({title: 'eCash received successfully', type: 'success'}); + } else { + showToast({title: 'This is an eCash token. Please select "Receive".', type: 'info'}); + } } + onClose(); }; const handleCopyToClipboard = () => { @@ -90,7 +99,9 @@ const ScanCashuQRCode: React.FC = ({onClose}) => { {scannedData && ( - {scannedData} + + {action === 'send' ? 'Pay this invoice' : 'Receive this eCash'} +