mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-06 03:38:24 +00:00
Disable receiving ecash over Nostr from an unknown mint
This commit is contained in:
Vendored
+1
-1
@@ -1 +1 @@
|
||||
01981501-ed07-7025-a18f-24fb4598fcd4
|
||||
0198388d-d8dc-72f2-b3e1-89f896656f07
|
||||
+1
-1
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user