diff --git a/src/modules/wallet/components/SendDialog.vue b/src/modules/wallet/components/SendDialog.vue index 20631e3..b963988 100644 --- a/src/modules/wallet/components/SendDialog.vue +++ b/src/modules/wallet/components/SendDialog.vue @@ -93,6 +93,30 @@ function parseBolt11Invoice(bolt11: string): ParsedInvoice | null { } } +function normalizePaymentRequest(request: string): string { + let normalized = request.trim() + const req = normalized.toLowerCase() + + // Handle Lightning URI prefix stripping (following LNbits implementation) + if (req.startsWith('lightning:')) { + normalized = normalized.slice(10) // Remove "lightning:" (10 chars) + } else if (req.startsWith('lnurl:')) { + normalized = normalized.slice(6) // Remove "lnurl:" (6 chars) + } else if (req.includes('lightning=lnurl1')) { + // Extract LNURL from lightning parameter + normalized = normalized.split('lightning=')[1].split('&')[0] + } else if (req.includes('lightning=')) { + // Handle BIP-21 Bitcoin URIs with Lightning fallback + normalized = normalized.split('lightning=')[1] + // Remove any additional query parameters + if (normalized.includes('&')) { + normalized = normalized.split('&')[0] + } + } + + return normalized.trim() +} + function parsePaymentDestination(destination: string) { // Clear previous parsing results parsedInvoice.value = null @@ -101,7 +125,8 @@ function parsePaymentDestination(destination: string) { if (!destination.trim()) return - const cleanDest = destination.trim() + // Normalize the destination by stripping URI prefixes + const cleanDest = normalizePaymentRequest(destination) if (isBolt11(cleanDest)) { paymentType.value = 'bolt11' @@ -198,8 +223,11 @@ const effectiveAmount = computed(() => { // Methods const onSubmit = form.handleSubmit(async (formValues) => { try { + // Use normalized destination (stripped of URI prefixes) + const normalizedDestination = normalizePaymentRequest(formValues.destination) + const success = await walletService.sendPayment({ - destination: formValues.destination, + destination: normalizedDestination, amount: effectiveAmount.value, // Use computed effective amount comment: formValues.comment || undefined })