mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 11:18:24 +00:00
Merge branch 'main' into i18n-automation
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minibits_wallet",
|
||||
"version": "0.1.8-beta.20",
|
||||
"version": "0.1.8-beta.21",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android:clean": "cd android && ./gradlew clean",
|
||||
|
||||
@@ -526,16 +526,22 @@ export const RemoteRecoveryScreen: FC<AppStackScreenProps<'RemoteRecovery'>> = o
|
||||
|
||||
setStatusMessage(translate("recovery.recoveringAddress"))
|
||||
setIsLoading(true)
|
||||
|
||||
const seedHash = QuickCrypto.createHash('sha256')
|
||||
.update(seed)
|
||||
.digest('hex')
|
||||
|
||||
// get nostr key from current on device profile
|
||||
const {publicKey: newPublicKey} = await NostrClient.getOrCreateKeyPair()
|
||||
|
||||
// delete orphaned server profile then update server profile with seedHash with pubkey + update on device wallet name and address
|
||||
await walletProfileStore.recover(seedHash as string, newPublicKey)
|
||||
|
||||
// align walletId in userSettings with recovered profile
|
||||
userSettingsStore.setWalletId(walletProfileStore.walletId)
|
||||
await KeyChain.saveMnemonic(mnemonic)
|
||||
await KeyChain.saveSeed(seed as Uint8Array)
|
||||
const seedHash = await KeyChain.loadSeedHash()
|
||||
|
||||
const {publicKey: newPublicKey} = await NostrClient.getOrCreateKeyPair()
|
||||
// Updates pubkey and imports wallet profile
|
||||
await walletProfileStore.recover(seedHash as string, newPublicKey)
|
||||
// Align walletId in userSettings with recovered profile
|
||||
userSettingsStore.setWalletId(walletProfileStore.walletId)
|
||||
|
||||
await delay(1000)
|
||||
setStatusMessage(translate("recovery.completed"))
|
||||
await delay(2000)
|
||||
|
||||
@@ -117,7 +117,7 @@ export const SendScreen: FC<WalletStackScreenProps<'Send'>> = observer(
|
||||
? amountInputRef.current.focus()
|
||||
: false
|
||||
}
|
||||
const timer = setTimeout(() => focus(), 100)
|
||||
const timer = setTimeout(() => focus(), 400)
|
||||
return () => {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
|
||||
@@ -13,11 +13,7 @@ import {
|
||||
Share,
|
||||
Image,
|
||||
ImageStyle,
|
||||
FlatList,
|
||||
Keyboard,
|
||||
} from 'react-native'
|
||||
import Clipboard from '@react-native-clipboard/clipboard'
|
||||
import QRCode from 'react-native-qrcode-svg'
|
||||
import {spacing, useThemeColor, colors, typography} from '../theme'
|
||||
import {WalletStackScreenProps} from '../navigation'
|
||||
import {
|
||||
@@ -151,16 +147,16 @@ export const TopupScreen: FC<WalletStackScreenProps<'Topup'>> = observer(
|
||||
useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const focus = () => {
|
||||
amountInputRef && amountInputRef.current
|
||||
? amountInputRef.current.focus()
|
||||
: false
|
||||
}
|
||||
const timer = setTimeout(() => focus(), 100)
|
||||
const focus = () => {
|
||||
amountInputRef && amountInputRef.current
|
||||
? amountInputRef.current.focus()
|
||||
: false
|
||||
}
|
||||
const timer = setTimeout(() => focus(), 400)
|
||||
|
||||
return () => {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
return () => {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -4,14 +4,14 @@ import { log } from './logService';
|
||||
import {
|
||||
MINIBIT_SERVER_NOSTR_PUBKEY,
|
||||
} from '@env'
|
||||
import { FirebaseMessagingTypes } from '@react-native-firebase/messaging';
|
||||
import { MintUnit, formatCurrency, getCurrency } from './wallet/currency';
|
||||
import { NostrClient, NostrProfile } from './nostrService';
|
||||
import AppError, { Err } from '../utils/AppError';
|
||||
import { Platform } from 'react-native';
|
||||
import { FirebaseMessagingTypes } from '@react-native-firebase/messaging'
|
||||
import { MintUnit, formatCurrency, getCurrency } from './wallet/currency'
|
||||
import { NostrClient, NostrProfile } from './nostrService'
|
||||
import AppError, { Err } from '../utils/AppError'
|
||||
import { Platform } from 'react-native'
|
||||
|
||||
export type RemoteMessageReceiveToLnurl = {
|
||||
type: 'RemoteMessageReceiveToLnurl',
|
||||
export type NotifyReceiveToLnurlData = {
|
||||
type: 'NotifyReceiveToLnurlData',
|
||||
data: {
|
||||
amount: number,
|
||||
unit: 'sat',
|
||||
@@ -32,21 +32,30 @@ const onReceiveRemoteNotification = async function(remoteMessage: FirebaseMessag
|
||||
}
|
||||
|
||||
const serverPubkey = MINIBIT_SERVER_NOSTR_PUBKEY
|
||||
|
||||
const decrypted = await NostrClient.decryptNip04(serverPubkey, encrypted as string)
|
||||
|
||||
if (decrypted) {
|
||||
const remoteData: RemoteMessageReceiveToLnurl = JSON.parse(decrypted)
|
||||
const {amount, unit, comment, zapSenderProfile} = remoteData.data
|
||||
|
||||
const currencyCode = getCurrency(unit as MintUnit).code
|
||||
|
||||
await createLocalNotification(
|
||||
`<b>⚡${formatCurrency(amount, currencyCode)} ${currencyCode}</b> incoming!`,
|
||||
`${zapSenderProfile ? 'Zap' : 'Payment'} from <b>${zapSenderProfile?.nip05 || 'unknown payer'}</b> is ready to be received.${comment ? ' Message from sender: ' + comment : ''}`,
|
||||
zapSenderProfile?.picture
|
||||
)
|
||||
if (!decrypted) {
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Unknown remote message data received', {data: remoteMessage.data})
|
||||
}
|
||||
|
||||
const remoteData = JSON.parse(decrypted)
|
||||
|
||||
// Remote notification building and showing per remoteData.type
|
||||
if(remoteData.type === 'NotifyReceiveToLnurlData' || remoteData.type === 'RemoteMessageReceiveToLnurl') {
|
||||
const {amount, unit, comment, zapSenderProfile} = remoteData.data
|
||||
const currencyCode = getCurrency(unit as MintUnit).code
|
||||
|
||||
await createLocalNotification(
|
||||
`<b>⚡${formatCurrency(amount, currencyCode)} ${currencyCode}</b> incoming!`,
|
||||
`${zapSenderProfile ? 'Zap' : 'Payment'} from <b>${zapSenderProfile?.nip05 || 'unknown payer'}</b> is ready to be received.${comment ? ' Message from sender: ' + comment : ''}`,
|
||||
zapSenderProfile?.picture
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Unknown remoteData.type', {remoteData})
|
||||
|
||||
} catch (e: any) {
|
||||
log.error(e.name, e.message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user