diff --git a/src/modules/market/composables/useMarket.ts b/src/modules/market/composables/useMarket.ts index 78b2937..b9cce29 100644 --- a/src/modules/market/composables/useMarket.ts +++ b/src/modules/market/composables/useMarket.ts @@ -5,6 +5,7 @@ import { config } from '@/lib/config' import { nostrmarketService } from '../services/nostrmarketService' import { nip04 } from 'nostr-tools' import { useAsyncOperation } from '@/core/composables/useAsyncOperation' +import { auth } from '@/composables/useAuth' // Nostr event kinds for market functionality const MARKET_EVENT_KINDS = { @@ -384,14 +385,29 @@ export function useMarket() { try { console.log('🔔 Received order-related DM:', event.id, 'from:', event.pubkey.slice(0, 8)) - const userPrivkey = authService.user.value?.prvkey + // Check both injected auth service AND global auth composable + const hasAuthService = authService.user.value?.prvkey + const hasGlobalAuth = auth.currentUser.value?.prvkey - if (!userPrivkey) { + const userPrivkey = hasAuthService ? authService.user.value.prvkey : auth.currentUser.value?.prvkey + const userPubkey = hasAuthService ? authService.user.value.pubkey : auth.currentUser.value?.pubkey + + if (!userPrivkey || !userPubkey) { console.warn('Cannot decrypt DM: no user private key available', { - authServicePrivkey: !!authService.user.value?.prvkey + hasAuthService: !!hasAuthService, + hasGlobalAuth: !!hasGlobalAuth, + authServicePrivkey: !!authService.user.value?.prvkey, + globalAuthPrivkey: !!auth.currentUser.value?.prvkey }) return } + + console.log('🔐 Market DM decryption auth check:', { + hasAuthService: !!hasAuthService, + hasGlobalAuth: !!hasGlobalAuth, + usingAuthService: !!hasAuthService, + userPubkey: userPubkey.substring(0, 10) + '...' + }) console.log('🔓 Attempting to decrypt DM with private key available')