mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 19:28:26 +00:00
Fix keyboard not showing when entering amount, fix address recovery from seed in case server return error
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",
|
||||
|
||||
@@ -522,16 +522,22 @@ export const RemoteRecoveryScreen: FC<AppStackScreenProps<'RemoteRecovery'>> = o
|
||||
|
||||
setStatusMessage('Recovering wallet address...')
|
||||
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(`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 {
|
||||
@@ -55,7 +51,6 @@ import useIsInternetReachable from '../utils/useIsInternetReachable'
|
||||
import { MintBalanceSelector } from './Mints/MintBalanceSelector'
|
||||
import { QRCodeBlock } from './Wallet/QRCode'
|
||||
import numbro from 'numbro'
|
||||
import { MintListItem } from './Mints/MintListItem'
|
||||
import { TranItem } from './TranDetailScreen'
|
||||
|
||||
if (
|
||||
@@ -116,7 +111,7 @@ export const TopupScreen: FC<WalletStackScreenProps<'Topup'>> = observer(
|
||||
? amountInputRef.current.focus()
|
||||
: false
|
||||
}
|
||||
const timer = setTimeout(() => focus(), 100)
|
||||
const timer = setTimeout(() => focus(), 400)
|
||||
|
||||
return () => {
|
||||
clearTimeout(timer)
|
||||
|
||||
@@ -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