Replace getWalletProfileByNip05 api by alternatives

This commit is contained in:
minibits-cash
2026-02-28 21:48:25 +01:00
parent 34c2086519
commit 13a27e9abe
3 changed files with 21 additions and 47 deletions
+3 -2
View File
@@ -4,7 +4,7 @@ import {Text as RNText, TextStyle, View, ViewStyle, TextInput, ScrollView } from
import {colors, spacing, typography, useThemeColor} from '../../theme'
import {BottomModal, Button, Card, ErrorModal, Icon, InfoModal, ListItem, Loading, Screen, Text} from '../../components'
import {useStores} from '../../models'
import { MinibitsClient} from '../../services'
import { MinibitsClient, NostrClient} from '../../services'
import AppError, { Err } from '../../utils/AppError'
import {log} from '../../services/logService'
import { TransactionStatus } from '../../models/Transaction'
@@ -160,7 +160,8 @@ export const OwnName = observer(function (props: {pubkey: string}) {
}
try {
const profileExists = await MinibitsClient.getWalletProfileByNip05(ownName + MINIBITS_NIP05_DOMAIN)
//const profileExists = await MinibitsClient.getWalletProfileByNip05(ownName + MINIBITS_NIP05_DOMAIN)
const profileExists = await NostrClient.getNip05Record(ownName + MINIBITS_NIP05_DOMAIN) // throws if not found
if(profileExists) {
setInfo(translate("contactsScreen_ownName_profileExists"))
+19 -42
View File
@@ -93,54 +93,31 @@ export const PrivateContacts = observer(function (props: {
try {
let newContact: Contact | undefined = undefined
let nostrProfile: NostrProfile | undefined = undefined
if (isExternalDomain) {
// validate and get profile data from nip05 server + relays
const profile = await NostrClient.getNormalizedNostrProfile(newContactName, relaysStore.allPublicUrls) as NostrProfile
log.trace('[saveNewContact]', 'Server profile', profile)
const {pubkey, npub, name, picture, nip05, lud16} = profile
newContact = {
type: ContactType.PRIVATE,
pubkey,
npub,
name,
picture,
nip05,
lud16,
isExternalDomain,
} as Contact
nostrProfile = await NostrClient.getNormalizedNostrProfile(newContactName, relaysStore.allPublicUrls) as NostrProfile
} else {
// do it with single api call for minibts.cash profiles
const profileRecord = await MinibitsClient.getWalletProfileByNip05(newContactName + MINIBITS_NIP05_DOMAIN)
if(!profileRecord) {
warningMessage(translate("contactsScreen_privateContacts_profileNotFound", {
name: newContactName + MINIBITS_NIP05_DOMAIN
}))
setIsLoading(false)
return
}
const npub = NostrClient.getNpubkey(profileRecord.pubkey)
const {pubkey, nip05, name, avatar: picture} = profileRecord
newContact = {
type: ContactType.PRIVATE,
pubkey,
npub,
nip05,
lud16: nip05, // minibits addresses are both nostr and lightning addresses
name,
picture,
isExternalDomain
} as Contact
// replaced insecure getWalletProfileByNip05 call
nostrProfile = await NostrClient.getNormalizedNostrProfile(newContactName, NostrClient.getMinibitsRelays()) as NostrProfile
}
log.trace('[saveNewContact]', 'Nostr profile', nostrProfile)
const {pubkey, npub, name, picture, nip05, lud16} = nostrProfile
newContact = {
type: ContactType.PRIVATE,
pubkey,
npub,
name,
picture,
nip05,
lud16,
isExternalDomain,
} as Contact
contactsStore.addContact(newContact)
setNewContactName('')
+1 -5
View File
@@ -2494,11 +2494,7 @@ const handleReceivedEventTask = async function (encryptedEvent: NostrEvent): Pro
&& userSettingsStore.isReceiveOnlyFromContactsOn === false
) {
const serverProfile = await MinibitsClient.getWalletProfileByNip05(sentFrom)
if(serverProfile.pubkey !== sentFromPubkey) {
throw new AppError(Err.UNAUTHORIZED_ERROR, 'Sender pubkey does not match the one on the Minibits server.', {sentFrom, sentFromPubkey, serverProfile})
}
const serverProfile = await MinibitsClient.getWalletProfile(sentFromPubkey)
log.info('[handleReceivedEventTask]', 'Event sent from Minibits server user, adding to contacts...', {sentFrom, sentFromPubkey})