diff --git a/dist/BUNDLE_ID b/dist/BUNDLE_ID index 3285870a..f90b36c5 100644 --- a/dist/BUNDLE_ID +++ b/dist/BUNDLE_ID @@ -1 +1 @@ -01981501-ed07-7025-a18f-24fb4598fcd4 \ No newline at end of file +0198388d-d8dc-72f2-b3e1-89f896656f07 \ No newline at end of file diff --git a/package.json b/package.json index af2d9235..a3972069 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minibits_wallet", - "version": "0.2.2-beta.27", + "version": "0.2.2-beta.28", "private": true, "scripts": { "android:clean": "cd android && ./gradlew clean", diff --git a/src/services/walletService.ts b/src/services/walletService.ts index f70ef323..ae49c682 100644 --- a/src/services/walletService.ts +++ b/src/services/walletService.ts @@ -2378,6 +2378,19 @@ const handleReceivedEventTask = async function (encryptedEvent: NostrEvent): Pro const amountToReceive = CashuUtils.getProofsAmount(decoded.proofs) const memo = decoded.memo || 'Received over Nostr' + // do not allow to receive automatically from unknown mints + if(!mintsStore.mintExists(decoded.mint)) { + let message = 'Receiving ecash token over Nostr from unknown mint is not allowed.' + + await _sendErrorReceiveNotification( + amountToReceive, + decoded.unit as MintUnit, + decoded.mint + ) + + throw new AppError(Err.VALIDATION_ERROR, message, {decoded}) + } + const {transaction, receivedAmount} = await receiveTask( decoded, amountToReceive, @@ -2679,6 +2692,41 @@ const _sendReceiveNotification = async function ( return } +const _sendErrorReceiveNotification = async function ( + amountToReceive: number, + unit: MintUnit, + mint: string +): Promise { + const getNotificationContent = ( + amount: number, + currency: CurrencyCode, + ): { title: string; body: string } => { + const title = Platform.OS === 'android' + ? `Received ${formatCurrency(amount, currency)} ${currency} ecash token from unknonw mint!` + : `Received ${formatCurrency(amount, currency)} ${currency} ecash token from unknonw mint!` + const body = Platform.OS === 'android' + ? `Add ${mint} to your wallet first to receive ecash over the Nostr network.` + : `Add ${mint} to your wallet first to receive ecash over the Nostr network.` + return { title, body }; + } + + const enabled = await NotificationService.areNotificationsEnabled() + if(!enabled) { + return + } + + // + // Send notification event + // + const currencyCode = getCurrency(unit).code + if(amountToReceive && amountToReceive > 0) { + const { title, body } = getNotificationContent(amountToReceive, currencyCode); + await NotificationService.createLocalNotification(title, body); + } + + return +} + const _sendIncomingInvoiceNotification = async function (amount: number, unit: MintUnit, from: Contact) { await NotificationService.createLocalNotification(