Disable receiving ecash over Nostr from an unknown mint

This commit is contained in:
minibits-cash
2025-07-24 22:28:41 +02:00
parent b433b21307
commit ebdd44523f
3 changed files with 50 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
01981501-ed07-7025-a18f-24fb4598fcd4
0198388d-d8dc-72f2-b3e1-89f896656f07
+1 -1
View File
@@ -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",
+48
View File
@@ -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<void> {
const getNotificationContent = (
amount: number,
currency: CurrencyCode,
): { title: string; body: string } => {
const title = Platform.OS === 'android'
? `<b>Received ${formatCurrency(amount, currency)} ${currency} ecash token from unknonw mint!</b>`
: `Received ${formatCurrency(amount, currency)} ${currency} ecash token from unknonw mint!`
const body = Platform.OS === 'android'
? `Add <b>${mint}</b> 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(