diff --git a/src/modules/wallet/components/ReceiveDialog.vue b/src/modules/wallet/components/ReceiveDialog.vue index fb1182b..40b37ce 100644 --- a/src/modules/wallet/components/ReceiveDialog.vue +++ b/src/modules/wallet/components/ReceiveDialog.vue @@ -3,6 +3,7 @@ import { ref, computed, nextTick } from 'vue' import { useForm } from 'vee-validate' import { toTypedSchema } from '@vee-validate/zod' import * as z from 'zod' +import { nip19 } from 'nostr-tools' import { injectService, SERVICE_TOKENS } from '@/core/di-container' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' @@ -106,13 +107,29 @@ async function copyToClipboard(text: string, field: string) { } } +function encodeLNURL(url: string): string { + try { + // Convert URL to bytes + const bytes = new TextEncoder().encode(url) + // Encode as bech32 with 'lnurl' prefix + const bech32 = nip19.encodeBytes('lnurl', bytes) + // Return with lightning: prefix in uppercase + return `lightning:${bech32.toUpperCase()}` + } catch (error) { + console.error('Failed to encode LNURL:', error) + return url // Fallback to original URL + } +} + async function generateQRCode(data: string) { if (!data) return - + isLoadingQR.value = true try { + // Encode LNURL with proper bech32 format and lightning: prefix + const encodedLNURL = encodeLNURL(data) // Use the existing PaymentService QR code generation - qrCode.value = await paymentService?.generateQRCode(data) + qrCode.value = await paymentService?.generateQRCode(encodedLNURL) } catch (error) { console.error('Failed to generate QR code:', error) toastService?.error('Failed to generate QR code') @@ -331,17 +348,37 @@ function onOpenChange(open: boolean) { - +
- +
- - +
+
+ + +
+ +
+ +