From 3ee765d2375f54129cb477e53c378c21a584cb33 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 11:52:29 -0400 Subject: [PATCH 001/114] REF: Proper file/dir structure for context providers --- App.tsx | 3 +-- components/CompanionDelegates.tsx | 2 +- .../Context/BlueStorageContext.tsx | 23 ++++++++----------- components/Context/SettingsContext.tsx | 10 +++----- components/DeviceQuickActions.tsx | 2 +- components/MenuElements.ios.tsx | 3 +-- components/TransactionListItem.tsx | 6 ++--- components/WalletsCarousel.js | 2 +- components/WatchConnectivity.ios.js | 2 +- components/WidgetCommunication.ios.tsx | 2 +- components/addresses/AddressItem.tsx | 2 +- hooks/context/useSettings.ts | 4 ++++ hooks/context/useStorage.ts | 4 ++++ hooks/useOnAppLaunch.ts | 2 +- screen/PlausibleDeniability.tsx | 2 +- screen/lnd/ldkInfo.tsx | 2 +- screen/lnd/lndCreateInvoice.js | 2 +- .../lndViewAdditionalInvoiceInformation.js | 2 +- screen/lnd/lndViewInvoice.js | 2 +- screen/lnd/lnurlAuth.js | 2 +- screen/receive/details.js | 2 +- screen/send/Confirm.tsx | 2 +- screen/send/coinControl.js | 8 +++---- screen/send/details.tsx | 2 +- screen/send/psbtMultisig.js | 2 +- screen/settings/SettingsPrivacy.tsx | 2 +- screen/settings/about.js | 2 +- screen/transactions/TransactionDetails.tsx | 2 +- screen/wallets/DrawerList.tsx | 2 +- .../ExportMultisigCoordinationSetup.tsx | 2 +- screen/wallets/addMultisigStep2.js | 2 +- screen/wallets/addresses.js | 2 +- screen/wallets/export.js | 2 +- screen/wallets/importCustomDerivationPath.js | 2 +- screen/wallets/importDiscovery.js | 2 +- screen/wallets/importSpeed.js | 2 +- screen/wallets/ldkViewLogs.js | 2 +- screen/wallets/pleaseBackupLNDHub.js | 2 +- screen/wallets/pleaseBackupLdk.js | 2 +- screen/wallets/reorderWallets.js | 2 +- screen/wallets/selectWallet.js | 2 +- screen/wallets/signVerify.js | 2 +- screen/wallets/xpub.tsx | 7 +++--- 43 files changed, 67 insertions(+), 69 deletions(-) rename blue_modules/storage-context.tsx => components/Context/BlueStorageContext.tsx (94%) create mode 100644 hooks/context/useSettings.ts create mode 100644 hooks/context/useStorage.ts diff --git a/App.tsx b/App.tsx index 1c98f69f80..390580ebd2 100644 --- a/App.tsx +++ b/App.tsx @@ -4,13 +4,12 @@ import { NavigationContainer } from '@react-navigation/native'; import React from 'react'; import { useColorScheme } from 'react-native'; import { SafeAreaProvider } from 'react-native-safe-area-context'; - -import { BlueStorageProvider } from './blue_modules/storage-context'; import { LargeScreenProvider } from './components/Context/LargeScreenProvider'; import { SettingsProvider } from './components/Context/SettingsContext'; import { BlueDarkTheme, BlueDefaultTheme } from './components/themes'; import MasterView from './navigation/MasterView'; import { navigationRef } from './NavigationService'; +import { BlueStorageProvider } from './components/Context/BlueStorageContext'; const App = () => { const colorScheme = useColorScheme(); diff --git a/components/CompanionDelegates.tsx b/components/CompanionDelegates.tsx index 28d7b3f1f4..87635743e8 100644 --- a/components/CompanionDelegates.tsx +++ b/components/CompanionDelegates.tsx @@ -9,13 +9,13 @@ import BlueClipboard from '../blue_modules/clipboard'; import { updateExchangeRate } from '../blue_modules/currency'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback'; import Notifications from '../blue_modules/notifications'; -import { useStorage } from '../blue_modules/storage-context'; import { LightningCustodianWallet } from '../class'; import DeeplinkSchemaMatch from '../class/deeplink-schema-match'; import loc from '../loc'; import { Chain } from '../models/bitcoinUnits'; import { navigationRef } from '../NavigationService'; import ActionSheet from '../screen/ActionSheet'; +import { useStorage } from '../hooks/context/useStorage'; const MenuElements = lazy(() => import('../components/MenuElements')); const DeviceQuickActions = lazy(() => import('../components/DeviceQuickActions')); diff --git a/blue_modules/storage-context.tsx b/components/Context/BlueStorageContext.tsx similarity index 94% rename from blue_modules/storage-context.tsx rename to components/Context/BlueStorageContext.tsx index b6ac8156f5..25646db841 100644 --- a/blue_modules/storage-context.tsx +++ b/components/Context/BlueStorageContext.tsx @@ -1,15 +1,14 @@ -import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'; +import React, { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { InteractionManager } from 'react-native'; - -import A from '../blue_modules/analytics'; -import Notifications from '../blue_modules/notifications'; -import { BlueApp as BlueAppClass, LegacyWallet, TCounterpartyMetadata, TTXMetadata, WatchOnlyWallet } from '../class'; -import type { TWallet } from '../class/wallets/types'; -import presentAlert from '../components/Alert'; -import loc from '../loc'; -import * as BlueElectrum from './BlueElectrum'; -import triggerHapticFeedback, { HapticFeedbackTypes } from './hapticFeedback'; -import { startAndDecrypt } from './start-and-decrypt'; +import A from '../../blue_modules/analytics'; +import Notifications from '../../blue_modules/notifications'; +import { BlueApp as BlueAppClass, LegacyWallet, TCounterpartyMetadata, TTXMetadata, WatchOnlyWallet } from '../../class'; +import type { TWallet } from '../../class/wallets/types'; +import presentAlert from '../../components/Alert'; +import loc from '../../loc'; +import * as BlueElectrum from '../../blue_modules/BlueElectrum'; +import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; +import { startAndDecrypt } from '../../blue_modules/start-and-decrypt'; const BlueApp = BlueAppClass.getInstance(); @@ -305,5 +304,3 @@ export const BlueStorageProvider = ({ children }: { children: React.ReactNode }) return {children}; }; - -export const useStorage = () => useContext(BlueStorageContext); diff --git a/components/Context/SettingsContext.tsx b/components/Context/SettingsContext.tsx index 8d1a36a088..c1b3a2cf5b 100644 --- a/components/Context/SettingsContext.tsx +++ b/components/Context/SettingsContext.tsx @@ -1,10 +1,8 @@ import { useAsyncStorage } from '@react-native-async-storage/async-storage'; -import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'; +import React, { createContext, useCallback, useEffect, useMemo, useState } from 'react'; import DefaultPreference from 'react-native-default-preference'; - import BlueClipboard from '../../blue_modules/clipboard'; import { getPreferredCurrency, GROUP_IO_BLUEWALLET, initCurrencyDaemon } from '../../blue_modules/currency'; -import { useStorage } from '../../blue_modules/storage-context'; import { clearUseURv1, isURv1Enabled, setUseURv1 } from '../../blue_modules/ur'; import { BlueApp } from '../../class'; import { saveLanguage, STORAGE_KEY } from '../../loc'; @@ -13,6 +11,7 @@ import { getEnabled as getIsDeviceQuickActionsEnabled, setEnabled as setIsDevice import presentAlert from '../Alert'; import { getIsHandOffUseEnabled, setIsHandOffUseEnabled } from '../HandOffComponent'; import { isBalanceDisplayAllowed, setBalanceDisplayAllowed } from '../WidgetCommunication'; +import { useStorage } from '../../hooks/context/useStorage'; interface SettingsContextType { preferredFiatCurrency: TFiatUnit; @@ -86,7 +85,6 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil const advancedModeStorage = useAsyncStorage(BlueApp.ADVANCED_MODE_ENABLED); const languageStorage = useAsyncStorage(STORAGE_KEY); - const { walletsInitialized } = useStorage(); useEffect(() => { @@ -282,6 +280,4 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil ); return {children}; -}; - -export const useSettings = () => useContext(SettingsContext); +}; \ No newline at end of file diff --git a/components/DeviceQuickActions.tsx b/components/DeviceQuickActions.tsx index 739a956d65..0ca764bbd0 100644 --- a/components/DeviceQuickActions.tsx +++ b/components/DeviceQuickActions.tsx @@ -32,7 +32,7 @@ export async function getEnabled(): Promise { } function DeviceQuickActions() { - const { wallets, walletsInitialized, isStorageEncrypted, addWallet, saveToDisk, setSharedCosigner } = useContext(BlueStorageContext); + const { wallets, walletsInitialized, isStorageEncrypted, addWallet, saveToDisk, setSharedCosigner } = useStorage(); const { preferredFiatCurrency, isQuickActionsEnabled } = useSettings(); const { isViewAllWalletsEnabled, getSelectedDefaultWallet } = useOnAppLaunch(); diff --git a/components/MenuElements.ios.tsx b/components/MenuElements.ios.tsx index c12abc0bfe..6e60b21e1c 100644 --- a/components/MenuElements.ios.tsx +++ b/components/MenuElements.ios.tsx @@ -1,7 +1,6 @@ import { CommonActions } from '@react-navigation/native'; import { useCallback, useContext, useEffect } from 'react'; import { NativeEventEmitter, NativeModules, Platform } from 'react-native'; - import { BlueStorageContext } from '../blue_modules/storage-context'; import * as NavigationService from '../NavigationService'; @@ -12,7 +11,7 @@ EventEmitter on the native side should receive a payload and rebuild menus. const eventEmitter = Platform.OS === 'ios' || Platform.OS === 'macos' ? new NativeEventEmitter(NativeModules.EventEmitter) : undefined; const MenuElements = () => { - const { walletsInitialized, reloadTransactionsMenuActionFunction } = useContext(BlueStorageContext); + const { walletsInitialized, reloadTransactionsMenuActionFunction } = useStorage(); // BlueWallet -> Settings const openSettings = useCallback(() => { diff --git a/components/TransactionListItem.tsx b/components/TransactionListItem.tsx index 8140a940e1..f9f6c861e7 100644 --- a/components/TransactionListItem.tsx +++ b/components/TransactionListItem.tsx @@ -1,8 +1,7 @@ -import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import AsyncStorage from '@react-native-async-storage/async-storage'; import Clipboard from '@react-native-clipboard/clipboard'; import { Linking, StyleSheet, View } from 'react-native'; -import { BlueStorageContext } from '../blue_modules/storage-context'; import Lnurl from '../class/lnurl'; import { LightningTransaction, Transaction } from '../class/wallets/types'; import TransactionExpiredIcon from '../components/icons/TransactionExpiredIcon'; @@ -22,6 +21,7 @@ import { Action, ToolTipMenuProps } from './types'; import { useExtendedNavigation } from '../hooks/useExtendedNavigation'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { DetailViewStackParamList } from '../navigation/DetailViewStackParamList'; +import { useStorage } from '../hooks/context/useStorage'; interface TransactionListItemProps { itemPriceUnit: BitcoinUnit; @@ -36,7 +36,7 @@ export const TransactionListItem: React.FC = React.mem const { colors } = useTheme(); const { navigate } = useExtendedNavigation(); const menuRef = useRef(); - const { txMetadata, counterpartyMetadata, wallets } = useContext(BlueStorageContext); + const { txMetadata, counterpartyMetadata, wallets } = useStorage(); const { preferredFiatCurrency, language } = useSettings(); const containerStyle = useMemo( () => ({ diff --git a/components/WalletsCarousel.js b/components/WalletsCarousel.js index 660696c93a..eeac502838 100644 --- a/components/WalletsCarousel.js +++ b/components/WalletsCarousel.js @@ -157,7 +157,7 @@ const iStyles = StyleSheet.create({ export const WalletCarouselItem = React.memo(({ item, _, onPress, handleLongPress, isSelectedWallet, customStyle }) => { const scaleValue = new Animated.Value(1.0); const { colors } = useTheme(); - const { walletTransactionUpdateStatus } = useContext(BlueStorageContext); + const { walletTransactionUpdateStatus } = useStorage(); const { width } = useWindowDimensions(); const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82; const isLargeScreen = useIsLargeScreen(); diff --git a/components/WatchConnectivity.ios.js b/components/WatchConnectivity.ios.js index 08d87b7664..774a19f4a9 100644 --- a/components/WatchConnectivity.ios.js +++ b/components/WatchConnectivity.ios.js @@ -17,7 +17,7 @@ import { FiatUnit } from '../models/fiatUnit'; import { useSettings } from './Context/SettingsContext'; function WatchConnectivity() { - const { walletsInitialized, wallets, fetchWalletTransactions, saveToDisk, txMetadata } = useContext(BlueStorageContext); + const { walletsInitialized, wallets, fetchWalletTransactions, saveToDisk, txMetadata } = useStorage(); const { preferredFiatCurrency } = useSettings(); const isReachable = useReachability(); const isInstalled = useInstalled(); // true | false diff --git a/components/WidgetCommunication.ios.tsx b/components/WidgetCommunication.ios.tsx index 5dcb3de305..77f360a19c 100644 --- a/components/WidgetCommunication.ios.tsx +++ b/components/WidgetCommunication.ios.tsx @@ -62,7 +62,7 @@ const allWalletsBalanceAndTransactionTime = async ( }; const WidgetCommunication: React.FC = () => { - const { wallets, walletsInitialized } = useContext(BlueStorageContext); + const { wallets, walletsInitialized } = useStorage(); const { isWidgetBalanceDisplayAllowed } = useSettings(); useEffect(() => { diff --git a/components/addresses/AddressItem.tsx b/components/addresses/AddressItem.tsx index f44a3514c2..f8ba7e1f4b 100644 --- a/components/addresses/AddressItem.tsx +++ b/components/addresses/AddressItem.tsx @@ -5,7 +5,6 @@ import { StyleSheet, Text, View } from 'react-native'; import { ListItem } from 'react-native-elements'; import Share from 'react-native-share'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage } from '../../blue_modules/storage-context'; import confirm from '../../helpers/confirm'; import { useBiometrics } from '../../hooks/useBiometrics'; import loc, { formatBalance } from '../../loc'; @@ -18,6 +17,7 @@ import { Action, ToolTipMenuProps } from '../types'; import { AddressTypeBadge } from './AddressTypeBadge'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamList'; +import { useStorage } from '../../hooks/context/useStorage'; interface AddressItemProps { // todo: fix `any` after addresses.js is converted to the church of holy typescript diff --git a/hooks/context/useSettings.ts b/hooks/context/useSettings.ts new file mode 100644 index 0000000000..c3b5dcd6ad --- /dev/null +++ b/hooks/context/useSettings.ts @@ -0,0 +1,4 @@ +import { useContext } from 'react'; +import { SettingsContext } from '../../components/Context/SettingsContext'; + +export const useSettings = () => useContext(SettingsContext); diff --git a/hooks/context/useStorage.ts b/hooks/context/useStorage.ts new file mode 100644 index 0000000000..5e4b846210 --- /dev/null +++ b/hooks/context/useStorage.ts @@ -0,0 +1,4 @@ +import { useContext } from 'react'; +import { BlueStorageContext } from '../../components/Context/BlueStorageContext'; + +export const useStorage = () => useStorage(); diff --git a/hooks/useOnAppLaunch.ts b/hooks/useOnAppLaunch.ts index a4a6de6058..c752d8fb75 100644 --- a/hooks/useOnAppLaunch.ts +++ b/hooks/useOnAppLaunch.ts @@ -5,7 +5,7 @@ import { TWallet } from '../class/wallets/types'; const useOnAppLaunch = () => { const STORAGE_KEY = 'ONAPP_LAUNCH_SELECTED_DEFAULT_WALLET_KEY'; - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const getSelectedDefaultWallet = useCallback(async (): Promise => { let selectedWallet: TWallet | undefined; diff --git a/screen/PlausibleDeniability.tsx b/screen/PlausibleDeniability.tsx index 98df4f9dd7..3cdd6e140f 100644 --- a/screen/PlausibleDeniability.tsx +++ b/screen/PlausibleDeniability.tsx @@ -38,7 +38,7 @@ function reducer(state: State, action: Action): State { // Component const PlausibleDeniability: React.FC = () => { - const { cachedPassword, isPasswordInUse, createFakeStorage, resetWallets } = useContext(BlueStorageContext); + const { cachedPassword, isPasswordInUse, createFakeStorage, resetWallets } = useStorage(); const [state, dispatch] = useReducer(reducer, initialState); const navigation = useNavigation>>(); diff --git a/screen/lnd/ldkInfo.tsx b/screen/lnd/ldkInfo.tsx index 42063b4e00..f03ab31335 100644 --- a/screen/lnd/ldkInfo.tsx +++ b/screen/lnd/ldkInfo.tsx @@ -34,7 +34,7 @@ type LdkInfoRouteProps = RouteProp< const LdkInfo = () => { const { walletID } = useRoute().params; - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const refreshDataInterval = useRef(); const sectionList = useRef(); const wallet = wallets.find(w => w.getID() === walletID) as LightningLdkWallet; diff --git a/screen/lnd/lndCreateInvoice.js b/screen/lnd/lndCreateInvoice.js index 31cb339353..eb879d0828 100644 --- a/screen/lnd/lndCreateInvoice.js +++ b/screen/lnd/lndCreateInvoice.js @@ -34,7 +34,7 @@ import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import * as NavigationService from '../../NavigationService'; const LNDCreateInvoice = () => { - const { wallets, saveToDisk, setSelectedWalletID } = useContext(BlueStorageContext); + const { wallets, saveToDisk, setSelectedWalletID } = useStorage(); const { walletID, uri } = useRoute().params; const wallet = useRef(wallets.find(item => item.getID() === walletID) || wallets.find(item => item.chain === Chain.OFFCHAIN)); const createInvoiceRef = useRef(); diff --git a/screen/lnd/lndViewAdditionalInvoiceInformation.js b/screen/lnd/lndViewAdditionalInvoiceInformation.js index 43fbce08d3..f0489096e6 100644 --- a/screen/lnd/lndViewAdditionalInvoiceInformation.js +++ b/screen/lnd/lndViewAdditionalInvoiceInformation.js @@ -14,7 +14,7 @@ import loc from '../../loc'; const LNDViewAdditionalInvoiceInformation = () => { const { walletID } = useRoute().params; - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const wallet = wallets.find(w => w.getID() === walletID); const [walletInfo, setWalletInfo] = useState(); const { colors } = useTheme(); diff --git a/screen/lnd/lndViewInvoice.js b/screen/lnd/lndViewInvoice.js index 25c9f9539e..a8c45b6252 100644 --- a/screen/lnd/lndViewInvoice.js +++ b/screen/lnd/lndViewInvoice.js @@ -19,7 +19,7 @@ import LNDCreateInvoice from './lndCreateInvoice'; const LNDViewInvoice = () => { const { invoice, walletID } = useRoute().params; - const { wallets, setSelectedWalletID, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext); + const { wallets, setSelectedWalletID, fetchAndSaveWalletTransactions } = useStorage(); const wallet = wallets.find(w => w.getID() === walletID); const { colors, closeImage } = useTheme(); const { goBack, navigate, setParams, setOptions, getParent } = useNavigation(); diff --git a/screen/lnd/lnurlAuth.js b/screen/lnd/lnurlAuth.js index af707b0d28..1500c110e9 100644 --- a/screen/lnd/lnurlAuth.js +++ b/screen/lnd/lnurlAuth.js @@ -24,7 +24,7 @@ const AuthState = { }; const LnurlAuth = () => { - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const { name } = useRoute(); const { walletID, lnurl } = useRoute().params; const wallet = useMemo(() => wallets.find(w => w.getID() === walletID), [wallets, walletID]); diff --git a/screen/receive/details.js b/screen/receive/details.js index c104bf25b4..a69c36c729 100644 --- a/screen/receive/details.js +++ b/screen/receive/details.js @@ -35,7 +35,7 @@ import { SuccessView } from '../send/success'; const ReceiveDetails = () => { const { walletID, address } = useRoute().params; - const { wallets, saveToDisk, sleep, isElectrumDisabled, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext); + const { wallets, saveToDisk, sleep, isElectrumDisabled, fetchAndSaveWalletTransactions } = useStorage(); const wallet = wallets.find(w => w.getID() === walletID); const [customLabel, setCustomLabel] = useState(); const [customAmount, setCustomAmount] = useState(); diff --git a/screen/send/Confirm.tsx b/screen/send/Confirm.tsx index 19126a2569..b0fcd1c3aa 100644 --- a/screen/send/Confirm.tsx +++ b/screen/send/Confirm.tsx @@ -66,7 +66,7 @@ type ConfirmRouteProp = RouteProp; type ConfirmNavigationProp = NativeStackNavigationProp; const Confirm: React.FC = () => { - const { wallets, fetchAndSaveWalletTransactions, counterpartyMetadata, isElectrumDisabled } = useContext(BlueStorageContext); + const { wallets, fetchAndSaveWalletTransactions, counterpartyMetadata, isElectrumDisabled } = useStorage(); const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); const navigation = useExtendedNavigation(); const route = useRoute(); // Get the route and its params diff --git a/screen/send/coinControl.js b/screen/send/coinControl.js index 2e215e4c90..c5701ec467 100644 --- a/screen/send/coinControl.js +++ b/screen/send/coinControl.js @@ -62,7 +62,7 @@ const OutputList = ({ onDeSelect, }) => { const { colors } = useTheme(); - const { txMetadata } = useContext(BlueStorageContext); + const { txMetadata } = useStorage(); const memo = oMemo || txMetadata[txid]?.memo || ''; const color = `#${txid.substring(0, 6)}`; const amount = formatBalance(value, balanceUnit, true); @@ -124,7 +124,7 @@ OutputList.propTypes = { const OutputModal = ({ item: { address, txid, value, vout, confirmations = 0 }, balanceUnit = BitcoinUnit.BTC, oMemo }) => { const { colors } = useTheme(); - const { txMetadata } = useContext(BlueStorageContext); + const { txMetadata } = useStorage(); const memo = oMemo || txMetadata[txid]?.memo || ''; const fullId = `${txid}:${vout}`; const color = `#${txid.substring(0, 6)}`; @@ -198,7 +198,7 @@ const mStyles = StyleSheet.create({ const OutputModalContent = ({ output, wallet, onUseCoin, frozen, setFrozen }) => { const { colors } = useTheme(); - const { txMetadata, saveToDisk } = useContext(BlueStorageContext); + const { txMetadata, saveToDisk } = useStorage(); const [memo, setMemo] = useState(wallet.getUTXOMetadata(output.txid, output.vout).memo || txMetadata[output.txid]?.memo || ''); const onMemoChange = value => setMemo(value); const switchValue = useMemo(() => ({ value: frozen, onValueChange: value => setFrozen(value) }), [frozen, setFrozen]); @@ -256,7 +256,7 @@ const CoinControl = () => { const navigation = useNavigation(); const { width } = useWindowDimensions(); const { walletID, onUTXOChoose } = useRoute().params; - const { wallets, saveToDisk, sleep } = useContext(BlueStorageContext); + const { wallets, saveToDisk, sleep } = useStorage(); const wallet = wallets.find(w => w.getID() === walletID); // sort by height ascending, txid , vout ascending const utxo = wallet.getUtxo(true).sort((a, b) => a.height - b.height || a.txid.localeCompare(b.txid) || a.vout - b.vout); diff --git a/screen/send/details.tsx b/screen/send/details.tsx index 0c88ead3ad..11d9d1d57e 100644 --- a/screen/send/details.tsx +++ b/screen/send/details.tsx @@ -75,7 +75,7 @@ type NavigationProps = NativeStackNavigationProp; const SendDetails = () => { - const { wallets, setSelectedWalletID, sleep, txMetadata, saveToDisk } = useContext(BlueStorageContext); + const { wallets, setSelectedWalletID, sleep, txMetadata, saveToDisk } = useStorage(); const navigation = useExtendedNavigation(); const route = useRoute(); const name = route.name; diff --git a/screen/send/psbtMultisig.js b/screen/send/psbtMultisig.js index fe0af7cc53..080cb1dcb6 100644 --- a/screen/send/psbtMultisig.js +++ b/screen/send/psbtMultisig.js @@ -20,7 +20,7 @@ const shortenAddress = addr => { }; const PsbtMultisig = () => { - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const { navigate, setParams } = useNavigation(); const { colors } = useTheme(); const [flatListHeight, setFlatListHeight] = useState(0); diff --git a/screen/settings/SettingsPrivacy.tsx b/screen/settings/SettingsPrivacy.tsx index 8d52e37d23..a92e009e3f 100644 --- a/screen/settings/SettingsPrivacy.tsx +++ b/screen/settings/SettingsPrivacy.tsx @@ -22,7 +22,7 @@ enum SettingsPrivacySection { const SettingsPrivacy: React.FC = () => { const { colors } = useTheme(); - const { isStorageEncrypted } = useContext(BlueStorageContext); + const { isStorageEncrypted } = useStorage(); const { isDoNotTrackEnabled, setDoNotTrackStorage, diff --git a/screen/settings/about.js b/screen/settings/about.js index 9e6bedd13b..b39aa61420 100644 --- a/screen/settings/about.js +++ b/screen/settings/about.js @@ -22,7 +22,7 @@ const About = () => { const { navigate } = useNavigation(); const { colors } = useTheme(); const { width, height } = useWindowDimensions(); - const { isElectrumDisabled } = useContext(BlueStorageContext); + const { isElectrumDisabled } = useStorage(); const styles = StyleSheet.create({ copyToClipboard: { justifyContent: 'center', diff --git a/screen/transactions/TransactionDetails.tsx b/screen/transactions/TransactionDetails.tsx index 77d4e98ac6..d7476b1c7c 100644 --- a/screen/transactions/TransactionDetails.tsx +++ b/screen/transactions/TransactionDetails.tsx @@ -69,7 +69,7 @@ type NavigationProps = NativeStackNavigationProp { const { setOptions, navigate } = useExtendedNavigation(); const { hash, walletID } = useRoute().params; - const { saveToDisk, txMetadata, counterpartyMetadata, wallets, getTransactions } = useContext(BlueStorageContext); + const { saveToDisk, txMetadata, counterpartyMetadata, wallets, getTransactions } = useStorage(); const [from, setFrom] = useState([]); const [to, setTo] = useState([]); const [isLoading, setIsLoading] = useState(true); diff --git a/screen/wallets/DrawerList.tsx b/screen/wallets/DrawerList.tsx index be36af71d6..134c13208e 100644 --- a/screen/wallets/DrawerList.tsx +++ b/screen/wallets/DrawerList.tsx @@ -84,7 +84,7 @@ const DrawerList: React.FC = memo(({ navigation }) => { const [state, dispatch] = useReducer(walletReducer, initialState); const walletsCarousel = useRef>(null); - const { wallets, selectedWalletID } = useContext(BlueStorageContext); + const { wallets, selectedWalletID } = useStorage(); const { colors } = useTheme(); const isFocused = useIsFocused(); diff --git a/screen/wallets/ExportMultisigCoordinationSetup.tsx b/screen/wallets/ExportMultisigCoordinationSetup.tsx index d3d225a961..0235e1e3bb 100644 --- a/screen/wallets/ExportMultisigCoordinationSetup.tsx +++ b/screen/wallets/ExportMultisigCoordinationSetup.tsx @@ -65,7 +65,7 @@ const ExportMultisigCoordinationSetup: React.FC = () => { const { isLoading, isShareButtonTapped, qrCodeContents } = state; const { params } = useRoute>(); const walletID = params.walletID; - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const wallet: TWallet | undefined = wallets.find(w => w.getID() === walletID); const dynamicQRCode = useRef(); const { colors } = useTheme(); diff --git a/screen/wallets/addMultisigStep2.js b/screen/wallets/addMultisigStep2.js index 3e22119660..d5c0759faa 100644 --- a/screen/wallets/addMultisigStep2.js +++ b/screen/wallets/addMultisigStep2.js @@ -44,7 +44,7 @@ import loc from '../../loc'; const staticCache = {}; const WalletsAddMultisigStep2 = () => { - const { addWallet, saveToDisk, isElectrumDisabled, sleep, currentSharedCosigner, setSharedCosigner } = useContext(BlueStorageContext); + const { addWallet, saveToDisk, isElectrumDisabled, sleep, currentSharedCosigner, setSharedCosigner } = useStorage(); const { isAdvancedModeEnabled } = useSettings(); const { colors } = useTheme(); diff --git a/screen/wallets/addresses.js b/screen/wallets/addresses.js index a3b9bbb41d..633e92388b 100644 --- a/screen/wallets/addresses.js +++ b/screen/wallets/addresses.js @@ -59,7 +59,7 @@ const WalletAddresses = () => { const [currentTab, setCurrentTab] = useState(TABS.EXTERNAL); - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const { walletID } = useRoute().params; diff --git a/screen/wallets/export.js b/screen/wallets/export.js index 9c5ab0d0ff..18902bd78b 100644 --- a/screen/wallets/export.js +++ b/screen/wallets/export.js @@ -14,7 +14,7 @@ import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; const WalletExport = () => { - const { wallets, saveToDisk } = useContext(BlueStorageContext); + const { wallets, saveToDisk } = useStorage(); const { walletID } = useRoute().params; const [isLoading, setIsLoading] = useState(true); const { goBack } = useNavigation(); diff --git a/screen/wallets/importCustomDerivationPath.js b/screen/wallets/importCustomDerivationPath.js index 3273f63d13..f1f2d77d7b 100644 --- a/screen/wallets/importCustomDerivationPath.js +++ b/screen/wallets/importCustomDerivationPath.js @@ -27,7 +27,7 @@ const ImportCustomDerivationPath = () => { const route = useRoute(); const importText = route.params.importText; const password = route.params.password; - const { addAndSaveWallet } = useContext(BlueStorageContext); + const { addAndSaveWallet } = useStorage(); const [path, setPath] = useState("m/84'/0'/0'"); const [wallets, setWallets] = useState({}); const [used, setUsed] = useState({}); diff --git a/screen/wallets/importDiscovery.js b/screen/wallets/importDiscovery.js index ecc24d7fee..177f057806 100644 --- a/screen/wallets/importDiscovery.js +++ b/screen/wallets/importDiscovery.js @@ -22,7 +22,7 @@ const ImportWalletDiscovery = () => { const route = useRoute(); const { importText, askPassphrase, searchAccounts } = route.params; const task = useRef(); - const { addAndSaveWallet } = useContext(BlueStorageContext); + const { addAndSaveWallet } = useStorage(); const [loading, setLoading] = useState(true); const [wallets, setWallets] = useState([]); const [password, setPassword] = useState(); diff --git a/screen/wallets/importSpeed.js b/screen/wallets/importSpeed.js index 3cb3e145f2..4304c98a0d 100644 --- a/screen/wallets/importSpeed.js +++ b/screen/wallets/importSpeed.js @@ -17,7 +17,7 @@ const WalletsImportWallet = () => { const [importText, setImportText] = useState(); const [walletType, setWalletType] = useState(); const [passphrase, setPassphrase] = useState(); - const { addAndSaveWallet } = useContext(BlueStorageContext); + const { addAndSaveWallet } = useStorage(); const styles = StyleSheet.create({ root: { diff --git a/screen/wallets/ldkViewLogs.js b/screen/wallets/ldkViewLogs.js index 0fc49a4001..038fd9128e 100644 --- a/screen/wallets/ldkViewLogs.js +++ b/screen/wallets/ldkViewLogs.js @@ -15,7 +15,7 @@ import loc from '../../loc'; const LdkViewLogs = () => { const { colors } = useTheme(); - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const { walletID } = useRoute().params; /** @type {LightningLdkWallet} */ const wallet = wallets.find(w => w.getID() === walletID); diff --git a/screen/wallets/pleaseBackupLNDHub.js b/screen/wallets/pleaseBackupLNDHub.js index 8d31b16d35..0459209db5 100644 --- a/screen/wallets/pleaseBackupLNDHub.js +++ b/screen/wallets/pleaseBackupLNDHub.js @@ -13,7 +13,7 @@ import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; const PleaseBackupLNDHub = () => { - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const { walletID } = useRoute().params; const wallet = wallets.find(w => w.getID() === walletID); const navigation = useNavigation(); diff --git a/screen/wallets/pleaseBackupLdk.js b/screen/wallets/pleaseBackupLdk.js index b7c5b382cf..88746be5b4 100644 --- a/screen/wallets/pleaseBackupLdk.js +++ b/screen/wallets/pleaseBackupLdk.js @@ -13,7 +13,7 @@ import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; const PleaseBackupLdk = () => { - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const { walletID } = useRoute().params; /** @type {LightningLdkWallet} */ const wallet = wallets.find(w => w.getID() === walletID); diff --git a/screen/wallets/reorderWallets.js b/screen/wallets/reorderWallets.js index 70d6f8899f..8e199e4150 100644 --- a/screen/wallets/reorderWallets.js +++ b/screen/wallets/reorderWallets.js @@ -22,7 +22,7 @@ const styles = StyleSheet.create({ const ReorderWallets = () => { const sortableList = useRef(); const { colors } = useTheme(); - const { wallets, setWalletsWithNewOrder } = useContext(BlueStorageContext); + const { wallets, setWalletsWithNewOrder } = useStorage(); const colorScheme = useColorScheme(); const { navigate, setOptions } = useExtendedNavigation(); const [searchQuery, setSearchQuery] = useState(''); diff --git a/screen/wallets/selectWallet.js b/screen/wallets/selectWallet.js index 8df53f5863..b47c30c117 100644 --- a/screen/wallets/selectWallet.js +++ b/screen/wallets/selectWallet.js @@ -18,7 +18,7 @@ const SelectWallet = () => { const { chainType, onWalletSelect, availableWallets, noWalletExplanationText, onChainRequireSend = false } = useRoute().params; const [isLoading, setIsLoading] = useState(true); const { pop, navigate, setOptions, getParent } = useNavigation(); - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const { colors, closeImage } = useTheme(); const isModal = useNavigationState(state => state.routes.length) === 1; let data = !onChainRequireSend diff --git a/screen/wallets/signVerify.js b/screen/wallets/signVerify.js index ea95c7c926..37eedcc42d 100644 --- a/screen/wallets/signVerify.js +++ b/screen/wallets/signVerify.js @@ -25,7 +25,7 @@ import loc from '../../loc'; const SignVerify = () => { const { colors } = useTheme(); - const { wallets, sleep } = useContext(BlueStorageContext); + const { wallets, sleep } = useStorage(); const { params } = useRoute(); const [isKeyboardVisible, setIsKeyboardVisible] = useState(false); const [address, setAddress] = useState(params.address ?? ''); diff --git a/screen/wallets/xpub.tsx b/screen/wallets/xpub.tsx index 845830e637..2fabe76f1d 100644 --- a/screen/wallets/xpub.tsx +++ b/screen/wallets/xpub.tsx @@ -1,9 +1,7 @@ import { NavigationProp, RouteProp, useFocusEffect, useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { ActivityIndicator, InteractionManager, View } from 'react-native'; import Share from 'react-native-share'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing20, BlueText } from '../../BlueComponents'; import Button from '../../components/Button'; import CopyTextToClipboard from '../../components/CopyTextToClipboard'; @@ -13,6 +11,7 @@ import SafeArea from '../../components/SafeArea'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; import { styles, useDynamicStyles } from './xpub.styles'; +import { useStorage } from '../../hooks/context/useStorage'; type WalletXpubRouteProp = RouteProp<{ params: { walletID: string; xpub: string } }, 'params'>; export type RootStackParamList = { @@ -23,7 +22,7 @@ export type RootStackParamList = { }; const WalletXpub: React.FC = () => { - const { wallets } = useContext(BlueStorageContext); + const { wallets } = useStorage(); const route = useRoute(); const { walletID, xpub } = route.params; const wallet = wallets.find(w => w.getID() === walletID); From e3b4b5e2f4586009bafc84301d69cccde915b14e Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 11:54:22 -0400 Subject: [PATCH 002/114] wip --- .../{SettingsContext.tsx => SettingsPriver.tsx} | 0 .../{BlueStorageContext.tsx => StorageProvider.tsx} | 10 +++++----- hooks/context/useSettings.ts | 2 +- hooks/context/useStorage.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename components/Context/{SettingsContext.tsx => SettingsPriver.tsx} (100%) rename components/Context/{BlueStorageContext.tsx => StorageProvider.tsx} (97%) diff --git a/components/Context/SettingsContext.tsx b/components/Context/SettingsPriver.tsx similarity index 100% rename from components/Context/SettingsContext.tsx rename to components/Context/SettingsPriver.tsx diff --git a/components/Context/BlueStorageContext.tsx b/components/Context/StorageProvider.tsx similarity index 97% rename from components/Context/BlueStorageContext.tsx rename to components/Context/StorageProvider.tsx index 25646db841..32a9fa82ef 100644 --- a/components/Context/BlueStorageContext.tsx +++ b/components/Context/StorageProvider.tsx @@ -15,7 +15,7 @@ const BlueApp = BlueAppClass.getInstance(); // hashmap of timestamps we _started_ refetching some wallet const _lastTimeTriedToRefetchWallet: { [walletID: string]: number } = {}; -interface BlueStorageContextType { +interface StorageContextType { wallets: TWallet[]; setWalletsWithNewOrder: (wallets: TWallet[]) => void; txMetadata: TTXMetadata; @@ -60,8 +60,8 @@ export enum WalletTransactionsStatus { ALL = 'ALL', } // @ts-ignore defaut value does not match the type -export const BlueStorageContext = createContext(undefined); -export const BlueStorageProvider = ({ children }: { children: React.ReactNode }) => { +export const StorageContext = createContext(undefined); +export const StorageProvider = ({ children }: { children: React.ReactNode }) => { const txMetadata = useRef(BlueApp.tx_metadata); const counterpartyMetadata = useRef(BlueApp.counterparty_metadata || {}); // init const getTransactions = BlueApp.getTransactions; @@ -231,7 +231,7 @@ export const BlueStorageProvider = ({ children }: { children: React.ReactNode }) [addWallet, saveToDisk, wallets], ); - const value: BlueStorageContextType = useMemo( + const value: StorageContextType = useMemo( () => ({ wallets, setWalletsWithNewOrder, @@ -302,5 +302,5 @@ export const BlueStorageProvider = ({ children }: { children: React.ReactNode }) ], ); - return {children}; + return {children}; }; diff --git a/hooks/context/useSettings.ts b/hooks/context/useSettings.ts index c3b5dcd6ad..a7a8bec034 100644 --- a/hooks/context/useSettings.ts +++ b/hooks/context/useSettings.ts @@ -1,4 +1,4 @@ import { useContext } from 'react'; -import { SettingsContext } from '../../components/Context/SettingsContext'; +import { SettingsContext } from '../../components/Context/SettingsPriver'; export const useSettings = () => useContext(SettingsContext); diff --git a/hooks/context/useStorage.ts b/hooks/context/useStorage.ts index 5e4b846210..4394e3d157 100644 --- a/hooks/context/useStorage.ts +++ b/hooks/context/useStorage.ts @@ -1,4 +1,4 @@ import { useContext } from 'react'; -import { BlueStorageContext } from '../../components/Context/BlueStorageContext'; +import { StorageContext } from '../../components/Context/StorageProvider'; -export const useStorage = () => useStorage(); +export const useStorage = () => useContext(StorageContext); From 3dbecedefbdb45fa4f6a062f3925e35ad26544e1 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 11:54:41 -0400 Subject: [PATCH 003/114] Update SettingsProvider.tsx --- components/Context/{SettingsPriver.tsx => SettingsProvider.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename components/Context/{SettingsPriver.tsx => SettingsProvider.tsx} (100%) diff --git a/components/Context/SettingsPriver.tsx b/components/Context/SettingsProvider.tsx similarity index 100% rename from components/Context/SettingsPriver.tsx rename to components/Context/SettingsProvider.tsx From f5977fcb5aab2de4aa6360bd3b7420098f6659fd Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 13:18:01 -0400 Subject: [PATCH 004/114] REF: Import directory --- App.tsx | 8 ++++---- MasterView.tsx | 3 +-- components/Context/SettingsProvider.tsx | 2 +- components/DeviceQuickActions.tsx | 7 +++---- components/HandOffComponent.ios.tsx | 3 +-- components/HandOffComponentListener.ios.tsx | 3 +-- components/MenuElements.ios.tsx | 4 ++-- components/TransactionListItem.tsx | 2 +- components/TransactionsNavigationHeader.tsx | 2 +- components/WalletsCarousel.js | 8 ++++---- components/WatchConnectivity.ios.js | 7 +++---- components/WidgetCommunication.ios.tsx | 7 +++---- hooks/context/useSettings.ts | 2 +- hooks/useBiometrics.ts | 2 +- hooks/useExtendedNavigation.ts | 2 +- hooks/useOnAppLaunch.ts | 4 ++-- hooks/usePrivacy.android.tsx | 2 +- hooks/usePrivacy.ios.tsx | 2 +- navigation/LazyLoadSendDetailsStack.tsx | 2 +- navigation/MasterView.tsx | 3 +-- navigation/index.tsx | 3 +-- screen/PlausibleDeniability.tsx | 5 ++--- screen/UnlockWith.tsx | 2 +- screen/lnd/ldkInfo.tsx | 5 ++--- screen/lnd/ldkOpenChannel.tsx | 3 +-- screen/lnd/lndCreateInvoice.js | 5 ++--- screen/lnd/lndViewAdditionalInvoiceInformation.js | 5 ++--- screen/lnd/lndViewInvoice.js | 10 +++++----- screen/lnd/lnurlAuth.js | 5 ++--- screen/receive/details.js | 4 ++-- screen/send/Confirm.tsx | 4 ++-- screen/send/{details.tsx => SendDetails.tsx} | 4 ++-- screen/send/coinControl.js | 5 ++--- screen/send/psbtMultisig.js | 9 +++++---- screen/settings/Currency.tsx | 2 +- screen/settings/DefaultView.tsx | 3 +-- screen/settings/EncryptStorage.tsx | 2 +- screen/settings/GeneralSettings.tsx | 5 ++--- screen/settings/Language.tsx | 3 +-- screen/settings/Settings.js | 3 +-- screen/settings/SettingsPrivacy.tsx | 7 +++---- screen/settings/about.js | 9 ++++----- screen/transactions/TransactionDetails.tsx | 5 ++--- screen/transactions/TransactionStatus.tsx | 3 +-- screen/wallets/Add.tsx | 8 ++++---- screen/wallets/DrawerList.tsx | 4 ++-- screen/wallets/ExportMultisigCoordinationSetup.tsx | 5 ++--- screen/wallets/PaymentCodesList.tsx | 5 ++--- screen/wallets/PleaseBackup.tsx | 5 ++--- screen/wallets/ViewEditMultisigCosigners.tsx | 7 +++---- screen/wallets/WalletsList.tsx | 5 ++--- screen/wallets/addMultisig.js | 2 +- screen/wallets/addMultisigStep2.js | 6 +++--- screen/wallets/addresses.js | 5 ++--- screen/wallets/details.js | 2 +- screen/wallets/export.js | 5 ++--- screen/wallets/import.js | 2 +- screen/wallets/importCustomDerivationPath.js | 5 ++--- screen/wallets/importDiscovery.js | 10 +++++----- screen/wallets/importSpeed.js | 5 ++--- screen/wallets/ldkViewLogs.js | 5 ++--- screen/wallets/pleaseBackupLNDHub.js | 5 ++--- screen/wallets/pleaseBackupLdk.js | 5 ++--- screen/wallets/reorderWallets.js | 5 ++--- screen/wallets/selectWallet.js | 5 ++--- screen/wallets/signVerify.js | 5 ++--- 66 files changed, 130 insertions(+), 167 deletions(-) rename screen/send/{details.tsx => SendDetails.tsx} (99%) diff --git a/App.tsx b/App.tsx index 390580ebd2..f549c7d02d 100644 --- a/App.tsx +++ b/App.tsx @@ -5,11 +5,11 @@ import React from 'react'; import { useColorScheme } from 'react-native'; import { SafeAreaProvider } from 'react-native-safe-area-context'; import { LargeScreenProvider } from './components/Context/LargeScreenProvider'; -import { SettingsProvider } from './components/Context/SettingsContext'; +import { SettingsProvider } from './components/Context/SettingsProvider'; import { BlueDarkTheme, BlueDefaultTheme } from './components/themes'; import MasterView from './navigation/MasterView'; import { navigationRef } from './NavigationService'; -import { BlueStorageProvider } from './components/Context/BlueStorageContext'; +import { StorageProvider } from './components/Context/StorageProvider'; const App = () => { const colorScheme = useColorScheme(); @@ -18,11 +18,11 @@ const App = () => { - + - + diff --git a/MasterView.tsx b/MasterView.tsx index 5180c86e38..e982d6207f 100644 --- a/MasterView.tsx +++ b/MasterView.tsx @@ -1,9 +1,8 @@ import 'react-native-gesture-handler'; // should be on top import React, { lazy, Suspense } from 'react'; - -import { useStorage } from './blue_modules/storage-context'; import MainRoot from './navigation'; +import { useStorage } from './hooks/context/useStorage'; const CompanionDelegates = lazy(() => import('./components/CompanionDelegates')); const MasterView = () => { diff --git a/components/Context/SettingsProvider.tsx b/components/Context/SettingsProvider.tsx index c1b3a2cf5b..aaa832e09a 100644 --- a/components/Context/SettingsProvider.tsx +++ b/components/Context/SettingsProvider.tsx @@ -280,4 +280,4 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil ); return {children}; -}; \ No newline at end of file +}; diff --git a/components/DeviceQuickActions.tsx b/components/DeviceQuickActions.tsx index 0ca764bbd0..36d72d921e 100644 --- a/components/DeviceQuickActions.tsx +++ b/components/DeviceQuickActions.tsx @@ -1,16 +1,15 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; import { CommonActions } from '@react-navigation/native'; -import { useContext, useEffect } from 'react'; +import { useEffect } from 'react'; import { DeviceEventEmitter, Linking, Platform } from 'react-native'; import QuickActions from 'react-native-quick-actions'; - -import { BlueStorageContext } from '../blue_modules/storage-context'; import DeeplinkSchemaMatch from '../class/deeplink-schema-match'; import { TWallet } from '../class/wallets/types'; -import { useSettings } from '../components/Context/SettingsContext'; import useOnAppLaunch from '../hooks/useOnAppLaunch'; import { formatBalance } from '../loc'; import * as NavigationService from '../NavigationService'; +import { useSettings } from '../hooks/context/useSettings'; +import { useStorage } from '../hooks/context/useStorage'; const DeviceQuickActionsStorageKey = 'DeviceQuickActionsEnabled'; diff --git a/components/HandOffComponent.ios.tsx b/components/HandOffComponent.ios.tsx index 3291429bbf..93df39d49d 100644 --- a/components/HandOffComponent.ios.tsx +++ b/components/HandOffComponent.ios.tsx @@ -2,10 +2,9 @@ import React from 'react'; import DefaultPreference from 'react-native-default-preference'; // @ts-ignore: react-native-handoff is not in the type definition import Handoff from 'react-native-handoff'; - import { GROUP_IO_BLUEWALLET } from '../blue_modules/currency'; import { BlueApp } from '../class'; -import { useSettings } from './Context/SettingsContext'; +import { useSettings } from '../hooks/context/useSettings'; interface HandOffComponentProps { url?: string; diff --git a/components/HandOffComponentListener.ios.tsx b/components/HandOffComponentListener.ios.tsx index 61d1c1311e..5da4aa30b7 100644 --- a/components/HandOffComponentListener.ios.tsx +++ b/components/HandOffComponentListener.ios.tsx @@ -1,9 +1,8 @@ import React, { useEffect } from 'react'; import { NativeEventEmitter, NativeModules } from 'react-native'; - -import { useStorage } from '../blue_modules/storage-context'; import * as NavigationService from '../NavigationService'; import HandOffComponent from './HandOffComponent.ios'; +import { useStorage } from '../hooks/context/useStorage'; interface UserActivityData { activityType: keyof typeof HandOffComponent.activityTypes; diff --git a/components/MenuElements.ios.tsx b/components/MenuElements.ios.tsx index 6e60b21e1c..34e171f7c5 100644 --- a/components/MenuElements.ios.tsx +++ b/components/MenuElements.ios.tsx @@ -1,8 +1,8 @@ import { CommonActions } from '@react-navigation/native'; -import { useCallback, useContext, useEffect } from 'react'; +import { useCallback, useEffect } from 'react'; import { NativeEventEmitter, NativeModules, Platform } from 'react-native'; -import { BlueStorageContext } from '../blue_modules/storage-context'; import * as NavigationService from '../NavigationService'; +import { useStorage } from '../hooks/context/useStorage'; /* Component for iPadOS and macOS menu items with keyboard shortcuts. diff --git a/components/TransactionListItem.tsx b/components/TransactionListItem.tsx index f9f6c861e7..3981541541 100644 --- a/components/TransactionListItem.tsx +++ b/components/TransactionListItem.tsx @@ -13,7 +13,7 @@ import TransactionOutgoingIcon from '../components/icons/TransactionOutgoingIcon import TransactionPendingIcon from '../components/icons/TransactionPendingIcon'; import loc, { formatBalanceWithoutSuffix, transactionTimeToReadable } from '../loc'; import { BitcoinUnit } from '../models/bitcoinUnits'; -import { useSettings } from './Context/SettingsContext'; +import { useSettings } from '../hooks/context/useSettings'; import ListItem from './ListItem'; import { useTheme } from './themes'; import ToolTipMenu from './TooltipMenu'; diff --git a/components/TransactionsNavigationHeader.tsx b/components/TransactionsNavigationHeader.tsx index fc0d8a5e57..31efb65123 100644 --- a/components/TransactionsNavigationHeader.tsx +++ b/components/TransactionsNavigationHeader.tsx @@ -10,7 +10,7 @@ import loc, { formatBalance, formatBalanceWithoutSuffix } from '../loc'; import { BitcoinUnit } from '../models/bitcoinUnits'; import { FiatUnit } from '../models/fiatUnit'; import { BlurredBalanceView } from './BlurredBalanceView'; -import { useSettings } from './Context/SettingsContext'; +import { useSettings } from '../hooks/context/useSettings'; import ToolTipMenu from './TooltipMenu'; import { ToolTipMenuProps } from './types'; diff --git a/components/WalletsCarousel.js b/components/WalletsCarousel.js index eeac502838..e6ffd09b29 100644 --- a/components/WalletsCarousel.js +++ b/components/WalletsCarousel.js @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import React, { forwardRef, useCallback, useContext, useImperativeHandle, useRef } from 'react'; +import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react'; import { Animated, FlatList, @@ -14,16 +14,16 @@ import { View, } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; - -import { BlueStorageContext, WalletTransactionsStatus } from '../blue_modules/storage-context'; import { BlueSpacing10 } from '../BlueComponents'; import { LightningCustodianWallet, LightningLdkWallet, MultisigHDWallet } from '../class'; import WalletGradient from '../class/wallet-gradient'; import { useIsLargeScreen } from '../hooks/useIsLargeScreen'; import loc, { formatBalance, transactionTimeToReadable } from '../loc'; import { BlurredBalanceView } from './BlurredBalanceView'; -import { useSettings } from './Context/SettingsContext'; +import { useSettings } from '../../hooks/context/useSettings'; import { useTheme } from './themes'; +import { useStorage } from '../hooks/context/useStorage'; +import { WalletTransactionsStatus } from './Context/StorageProvider'; const nStyles = StyleSheet.create({ container: { diff --git a/components/WatchConnectivity.ios.js b/components/WatchConnectivity.ios.js index 774a19f4a9..880d54eee7 100644 --- a/components/WatchConnectivity.ios.js +++ b/components/WatchConnectivity.ios.js @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useRef } from 'react'; +import React, { useEffect, useRef } from 'react'; import { transferCurrentComplicationUserInfo, transferUserInfo, @@ -7,14 +7,13 @@ import { useReachability, watchEvents, } from 'react-native-watch-connectivity'; - import Notifications from '../blue_modules/notifications'; -import { BlueStorageContext } from '../blue_modules/storage-context'; import { MultisigHDWallet } from '../class'; import loc, { formatBalance, transactionTimeToReadable } from '../loc'; import { Chain } from '../models/bitcoinUnits'; import { FiatUnit } from '../models/fiatUnit'; -import { useSettings } from './Context/SettingsContext'; +import { useSettings } from '../hooks/context/useSettings'; +import { useStorage } from '../hooks/context/useStorage'; function WatchConnectivity() { const { walletsInitialized, wallets, fetchWalletTransactions, saveToDisk, txMetadata } = useStorage(); diff --git a/components/WidgetCommunication.ios.tsx b/components/WidgetCommunication.ios.tsx index 77f360a19c..03f6fe6164 100644 --- a/components/WidgetCommunication.ios.tsx +++ b/components/WidgetCommunication.ios.tsx @@ -1,9 +1,8 @@ -import React, { useContext, useEffect } from 'react'; +import React, { useEffect } from 'react'; import DefaultPreference from 'react-native-default-preference'; - -import { BlueStorageContext } from '../blue_modules/storage-context'; import { TWallet } from '../class/wallets/types'; -import { useSettings } from './Context/SettingsContext'; +import { useSettings } from '../hooks/context/useSettings'; +import { useStorage } from '../hooks/context/useStorage'; enum WidgetCommunicationKeys { AllWalletsSatoshiBalance = 'WidgetCommunicationAllWalletsSatoshiBalance', diff --git a/hooks/context/useSettings.ts b/hooks/context/useSettings.ts index a7a8bec034..2af1959e0c 100644 --- a/hooks/context/useSettings.ts +++ b/hooks/context/useSettings.ts @@ -1,4 +1,4 @@ import { useContext } from 'react'; -import { SettingsContext } from '../../components/Context/SettingsPriver'; +import { SettingsContext } from '../../components/Context/SettingsProvider'; export const useSettings = () => useContext(SettingsContext); diff --git a/hooks/useBiometrics.ts b/hooks/useBiometrics.ts index 4a60714b96..efa334c295 100644 --- a/hooks/useBiometrics.ts +++ b/hooks/useBiometrics.ts @@ -5,8 +5,8 @@ import PasscodeAuth from 'react-native-passcode-auth'; import RNSecureKeyStore, { ACCESSIBLE } from 'react-native-secure-key-store'; import loc from '../loc'; import * as NavigationService from '../NavigationService'; -import { useStorage } from '../blue_modules/storage-context'; import presentAlert from '../components/Alert'; +import { useStorage } from './context/useStorage'; const STORAGEKEY = 'Biometrics'; const rnBiometrics = new ReactNativeBiometrics({ allowDeviceCredentials: true }); diff --git a/hooks/useExtendedNavigation.ts b/hooks/useExtendedNavigation.ts index 7da7f4d19c..82216f055a 100644 --- a/hooks/useExtendedNavigation.ts +++ b/hooks/useExtendedNavigation.ts @@ -1,8 +1,8 @@ import { useNavigation, NavigationProp, ParamListBase } from '@react-navigation/native'; import { navigationRef } from '../NavigationService'; -import { useStorage } from '../blue_modules/storage-context'; import { presentWalletExportReminder } from '../helpers/presentWalletExportReminder'; import { useBiometrics } from './useBiometrics'; +import { useStorage } from './context/useStorage'; // List of screens that require biometrics const requiresBiometrics = ['WalletExportRoot', 'WalletXpubRoot', 'ViewEditMultisigCosignersRoot', 'ExportMultisigCoordinationSetupRoot']; diff --git a/hooks/useOnAppLaunch.ts b/hooks/useOnAppLaunch.ts index c752d8fb75..c3fb7b7e18 100644 --- a/hooks/useOnAppLaunch.ts +++ b/hooks/useOnAppLaunch.ts @@ -1,7 +1,7 @@ -import { useCallback, useContext } from 'react'; +import { useCallback } from 'react'; import AsyncStorage from '@react-native-async-storage/async-storage'; -import { BlueStorageContext } from '../blue_modules/storage-context'; import { TWallet } from '../class/wallets/types'; +import { useStorage } from './context/useStorage'; const useOnAppLaunch = () => { const STORAGE_KEY = 'ONAPP_LAUNCH_SELECTED_DEFAULT_WALLET_KEY'; diff --git a/hooks/usePrivacy.android.tsx b/hooks/usePrivacy.android.tsx index f8c6f81b0e..68bc751c2d 100644 --- a/hooks/usePrivacy.android.tsx +++ b/hooks/usePrivacy.android.tsx @@ -1,7 +1,7 @@ import { useEffect, useCallback } from 'react'; // @ts-ignore: react-native-obscure is not in the type definition import Obscure from 'react-native-obscure'; -import { useSettings } from '../components/Context/SettingsContext'; +import { useSettings } from './context/useSettings'; export const usePrivacy = () => { const { isPrivacyBlurEnabled } = useSettings(); diff --git a/hooks/usePrivacy.ios.tsx b/hooks/usePrivacy.ios.tsx index f2812880fa..f9342cb2dc 100644 --- a/hooks/usePrivacy.ios.tsx +++ b/hooks/usePrivacy.ios.tsx @@ -1,7 +1,7 @@ import { useEffect, useCallback } from 'react'; // @ts-ignore: react-native-obscure is not in the type definition import { enabled } from 'react-native-privacy-snapshot'; -import { useSettings } from '../components/Context/SettingsContext'; +import { useSettings } from './context/useSettings'; export const usePrivacy = () => { const { isPrivacyBlurEnabled } = useSettings(); diff --git a/navigation/LazyLoadSendDetailsStack.tsx b/navigation/LazyLoadSendDetailsStack.tsx index f06199696f..e269843069 100644 --- a/navigation/LazyLoadSendDetailsStack.tsx +++ b/navigation/LazyLoadSendDetailsStack.tsx @@ -2,7 +2,7 @@ import React, { lazy, Suspense } from 'react'; import { LazyLoadingIndicator } from './LazyLoadingIndicator'; -const SendDetails = lazy(() => import('../screen/send/details')); +const SendDetails = lazy(() => import('../screen/send/SendDetails')); const Confirm = lazy(() => import('../screen/send/Confirm')); const PsbtWithHardwareWallet = lazy(() => import('../screen/send/psbtWithHardwareWallet')); const CreateTransaction = lazy(() => import('../screen/send/create')); diff --git a/navigation/MasterView.tsx b/navigation/MasterView.tsx index e7581c1d70..18212ef14e 100644 --- a/navigation/MasterView.tsx +++ b/navigation/MasterView.tsx @@ -1,9 +1,8 @@ import 'react-native-gesture-handler'; // should be on top import React, { lazy, Suspense } from 'react'; - -import { useStorage } from '../blue_modules/storage-context'; import MainRoot from '../navigation'; +import { useStorage } from '../hooks/context/useStorage'; const CompanionDelegates = lazy(() => import('../components/CompanionDelegates')); const MasterView = () => { diff --git a/navigation/index.tsx b/navigation/index.tsx index f9d3d872c7..e8f9f1443d 100644 --- a/navigation/index.tsx +++ b/navigation/index.tsx @@ -1,11 +1,10 @@ import { createNativeStackNavigator, NativeStackNavigationOptions } from '@react-navigation/native-stack'; import React, { lazy, Suspense } from 'react'; - import { isHandset } from '../blue_modules/environment'; -import { useStorage } from '../blue_modules/storage-context'; import UnlockWith from '../screen/UnlockWith'; import { LazyLoadingIndicator } from './LazyLoadingIndicator'; import { DetailViewStackParamList } from './DetailViewStackParamList'; +import { useStorage } from '../hooks/context/useStorage'; const DetailViewScreensStack = lazy(() => import('./DetailViewScreensStack')); const DrawerRoot = lazy(() => import('./DrawerRoot')); diff --git a/screen/PlausibleDeniability.tsx b/screen/PlausibleDeniability.tsx index 3cdd6e140f..6d6074d093 100644 --- a/screen/PlausibleDeniability.tsx +++ b/screen/PlausibleDeniability.tsx @@ -1,15 +1,14 @@ import { useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; -import React, { useContext, useReducer } from 'react'; +import React, { useReducer } from 'react'; import { ScrollView } from 'react-native'; - import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../blue_modules/storage-context'; import { BlueCard, BlueLoading, BlueSpacing20, BlueText } from '../BlueComponents'; import presentAlert from '../components/Alert'; import Button from '../components/Button'; import prompt from '../helpers/prompt'; import loc from '../loc'; +import { useStorage } from '../hooks/context/useStorage'; // Action Types const SET_LOADING = 'SET_LOADING'; diff --git a/screen/UnlockWith.tsx b/screen/UnlockWith.tsx index 841a35b32e..d2b09085a5 100644 --- a/screen/UnlockWith.tsx +++ b/screen/UnlockWith.tsx @@ -1,12 +1,12 @@ import React, { useCallback, useEffect, useReducer, useRef } from 'react'; import { ActivityIndicator, Image, StyleSheet, View } from 'react-native'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback'; -import { useStorage } from '../blue_modules/storage-context'; import { BlueTextCentered } from '../BlueComponents'; import Button from '../components/Button'; import SafeArea from '../components/SafeArea'; import { BiometricType, useBiometrics } from '../hooks/useBiometrics'; import loc from '../loc'; +import { useStorage } from '../hooks/context/useStorage'; enum AuthType { Encrypted, diff --git a/screen/lnd/ldkInfo.tsx b/screen/lnd/ldkInfo.tsx index f03ab31335..066a2a198c 100644 --- a/screen/lnd/ldkInfo.tsx +++ b/screen/lnd/ldkInfo.tsx @@ -1,9 +1,7 @@ import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'; import { Psbt } from 'bitcoinjs-lib'; -import React, { useContext, useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { Keyboard, SectionList, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueLoading, BlueSpacing10, BlueSpacing20, BlueTextCentered } from '../../BlueComponents'; import { LightningLdkWallet } from '../../class'; import { TWallet } from '../../class/wallets/types'; @@ -19,6 +17,7 @@ import confirm from '../../helpers/confirm'; import selectWallet from '../../helpers/select-wallet'; import loc, { formatBalance } from '../../loc'; import { Chain } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; const LdkNodeInfoChannelStatus = { ACTIVE: 'Active', INACTIVE: 'Inactive', PENDING: 'PENDING', STATUS: 'status' }; diff --git a/screen/lnd/ldkOpenChannel.tsx b/screen/lnd/ldkOpenChannel.tsx index 752cf743e5..765bd999a4 100644 --- a/screen/lnd/ldkOpenChannel.tsx +++ b/screen/lnd/ldkOpenChannel.tsx @@ -3,10 +3,8 @@ import BigNumber from 'bignumber.js'; import { Psbt } from 'bitcoinjs-lib'; import React, { useEffect, useRef, useState } from 'react'; import { StyleSheet, View } from 'react-native'; - import { btcToSatoshi, fiatToBTC } from '../../blue_modules/currency'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueDismissKeyboardInputAccessory, BlueLoading, BlueSpacing20, BlueText } from '../../BlueComponents'; import { HDSegwitBech32Wallet, LightningLdkWallet } from '../../class'; import AddressInput from '../../components/AddressInput'; @@ -19,6 +17,7 @@ import { useTheme } from '../../components/themes'; import { useBiometrics } from '../../hooks/useBiometrics'; import loc from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; type LdkOpenChannelProps = RouteProp< { diff --git a/screen/lnd/lndCreateInvoice.js b/screen/lnd/lndCreateInvoice.js index eb879d0828..549892d98e 100644 --- a/screen/lnd/lndCreateInvoice.js +++ b/screen/lnd/lndCreateInvoice.js @@ -1,5 +1,5 @@ +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; import { ActivityIndicator, I18nManager, @@ -16,11 +16,9 @@ import { } from 'react-native'; import { Icon } from 'react-native-elements'; import { parse } from 'url'; // eslint-disable-line n/no-deprecated-api - import { btcToSatoshi, fiatToBTC, satoshiToBTC } from '../../blue_modules/currency'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import Notifications from '../../blue_modules/notifications'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueDismissKeyboardInputAccessory, BlueLoading } from '../../BlueComponents'; import Lnurl from '../../class/lnurl'; import presentAlert from '../../components/Alert'; @@ -32,6 +30,7 @@ import { requestCameraAuthorization } from '../../helpers/scan-qr'; import loc, { formatBalance, formatBalancePlain, formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import * as NavigationService from '../../NavigationService'; +import { useStorage } from '../../hooks/context/useStorage'; const LNDCreateInvoice = () => { const { wallets, saveToDisk, setSelectedWalletID } = useStorage(); diff --git a/screen/lnd/lndViewAdditionalInvoiceInformation.js b/screen/lnd/lndViewAdditionalInvoiceInformation.js index f0489096e6..44ed18b7d3 100644 --- a/screen/lnd/lndViewAdditionalInvoiceInformation.js +++ b/screen/lnd/lndViewAdditionalInvoiceInformation.js @@ -1,8 +1,6 @@ import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useContext, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Share, StyleSheet, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueLoading, BlueSpacing20, BlueText } from '../../BlueComponents'; import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; @@ -11,6 +9,7 @@ import QRCodeComponent from '../../components/QRCodeComponent'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const LNDViewAdditionalInvoiceInformation = () => { const { walletID } = useRoute().params; diff --git a/screen/lnd/lndViewInvoice.js b/screen/lnd/lndViewInvoice.js index a8c45b6252..4e3da91dcc 100644 --- a/screen/lnd/lndViewInvoice.js +++ b/screen/lnd/lndViewInvoice.js @@ -1,11 +1,9 @@ -import { useNavigation, useNavigationState, useRoute } from '@react-navigation/native'; -import React, { useContext, useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; +import { useNavigationState, useRoute } from '@react-navigation/native'; import { BackHandler, I18nManager, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { Icon } from 'react-native-elements'; import Share from 'react-native-share'; - import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueLoading, BlueSpacing20, BlueText, BlueTextCentered } from '../../BlueComponents'; import Button from '../../components/Button'; import CopyTextToClipboard from '../../components/CopyTextToClipboard'; @@ -16,13 +14,15 @@ import loc from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; import { SuccessView } from '../send/success'; import LNDCreateInvoice from './lndCreateInvoice'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; const LNDViewInvoice = () => { const { invoice, walletID } = useRoute().params; const { wallets, setSelectedWalletID, fetchAndSaveWalletTransactions } = useStorage(); const wallet = wallets.find(w => w.getID() === walletID); const { colors, closeImage } = useTheme(); - const { goBack, navigate, setParams, setOptions, getParent } = useNavigation(); + const { goBack, navigate, setParams, setOptions, getParent } = useExtendedNavigation(); const [isLoading, setIsLoading] = useState(typeof invoice === 'string'); const [isFetchingInvoices, setIsFetchingInvoices] = useState(true); const [invoiceStatusChanged, setInvoiceStatusChanged] = useState(false); diff --git a/screen/lnd/lnurlAuth.js b/screen/lnd/lnurlAuth.js index 1500c110e9..ebe25ba7f3 100644 --- a/screen/lnd/lnurlAuth.js +++ b/screen/lnd/lnurlAuth.js @@ -1,10 +1,8 @@ import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useMemo, useState } from 'react'; +import React, { useCallback, useMemo, useState } from 'react'; import { I18nManager, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { Icon } from 'react-native-elements'; import URL from 'url'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueCard, BlueLoading, BlueSpacing20, BlueSpacing40, BlueText } from '../../BlueComponents'; import Lnurl from '../../class/lnurl'; import Button from '../../components/Button'; @@ -15,6 +13,7 @@ import selectWallet from '../../helpers/select-wallet'; import loc from '../../loc'; import { Chain } from '../../models/bitcoinUnits'; import { SuccessView } from '../send/success'; +import { useStorage } from '../../hooks/context/useStorage'; const AuthState = { USER_PROMPT: 0, diff --git a/screen/receive/details.js b/screen/receive/details.js index a69c36c729..4371228f6d 100644 --- a/screen/receive/details.js +++ b/screen/receive/details.js @@ -1,5 +1,5 @@ import { useFocusEffect, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { BackHandler, InteractionManager, @@ -17,7 +17,6 @@ import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import { fiatToBTC, satoshiToBTC } from '../../blue_modules/currency'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import Notifications from '../../blue_modules/notifications'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueButtonLink, BlueCard, BlueLoading, BlueSpacing20, BlueSpacing40, BlueText } from '../../BlueComponents'; import DeeplinkSchemaMatch from '../../class/deeplink-schema-match'; import AmountInput from '../../components/AmountInput'; @@ -32,6 +31,7 @@ import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc, { formatBalance } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import { SuccessView } from '../send/success'; +import { useStorage } from '../../hooks/context/useStorage'; const ReceiveDetails = () => { const { walletID, address } = useRoute().params; diff --git a/screen/send/Confirm.tsx b/screen/send/Confirm.tsx index bf0b122d8b..b9ef0f3b83 100644 --- a/screen/send/Confirm.tsx +++ b/screen/send/Confirm.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useMemo, useReducer } from 'react'; +import React, { useEffect, useMemo, useReducer } from 'react'; import { ActivityIndicator, FlatList, TouchableOpacity, StyleSheet, Switch, View } from 'react-native'; import { Text } from 'react-native-elements'; import { PayjoinClient } from 'payjoin-client'; @@ -8,7 +8,6 @@ import { BlueText, BlueCard } from '../../BlueComponents'; import { BitcoinUnit } from '../../models/bitcoinUnits'; import loc, { formatBalance, formatBalanceWithoutSuffix } from '../../loc'; import Notifications from '../../blue_modules/notifications'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { useRoute, RouteProp } from '@react-navigation/native'; import presentAlert from '../../components/Alert'; import { useTheme } from '../../components/themes'; @@ -24,6 +23,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { SendDetailsStackParamList } from '../../navigation/SendDetailsStackParamList'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import { ContactList } from '../../class/contact-list'; +import { useStorage } from '../../hooks/context/useStorage'; enum ActionType { SET_LOADING = 'SET_LOADING', diff --git a/screen/send/details.tsx b/screen/send/SendDetails.tsx similarity index 99% rename from screen/send/details.tsx rename to screen/send/SendDetails.tsx index 11d9d1d57e..2014c10c61 100644 --- a/screen/send/details.tsx +++ b/screen/send/SendDetails.tsx @@ -2,7 +2,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; import { RouteProp, StackActions, useFocusEffect, useRoute } from '@react-navigation/native'; import BigNumber from 'bignumber.js'; import * as bitcoin from 'bitcoinjs-lib'; -import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { ActivityIndicator, Alert, @@ -29,7 +29,6 @@ import RNFS from 'react-native-fs'; import { btcToSatoshi, fiatToBTC } from '../../blue_modules/currency'; import * as fs from '../../blue_modules/fs'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueDismissKeyboardInputAccessory, BlueLoading, BlueText } from '../../BlueComponents'; import { HDSegwitBech32Wallet, MultisigHDWallet, WatchOnlyWallet } from '../../class'; import DeeplinkSchemaMatch from '../../class/deeplink-schema-match'; @@ -57,6 +56,7 @@ import { SendDetailsStackParamList } from '../../navigation/SendDetailsStackPara import { isTablet } from '../../blue_modules/environment'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import { ContactList } from '../../class/contact-list'; +import { useStorage } from '../../hooks/context/useStorage'; interface IPaymentDestinations { address: string; // btc address or payment code diff --git a/screen/send/coinControl.js b/screen/send/coinControl.js index c5701ec467..fc918941d8 100644 --- a/screen/send/coinControl.js +++ b/screen/send/coinControl.js @@ -1,6 +1,6 @@ import { useNavigation, useRoute } from '@react-navigation/native'; import PropTypes from 'prop-types'; -import React, { useContext, useEffect, useMemo, useRef, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import { ActivityIndicator, FlatList, @@ -18,9 +18,7 @@ import { } from 'react-native'; import { Avatar, Badge, Icon, ListItem as RNElementsListItem } from 'react-native-elements'; import * as RNLocalize from 'react-native-localize'; - import debounce from '../../blue_modules/debounce'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing10, BlueSpacing20 } from '../../BlueComponents'; import BottomModal from '../../components/BottomModal'; import Button from '../../components/Button'; @@ -30,6 +28,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc, { formatBalance } from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; const FrozenBadge = () => { const { colors } = useTheme(); diff --git a/screen/send/psbtMultisig.js b/screen/send/psbtMultisig.js index 080cb1dcb6..15bb02abd7 100644 --- a/screen/send/psbtMultisig.js +++ b/screen/send/psbtMultisig.js @@ -1,12 +1,11 @@ -import { useNavigation, useRoute } from '@react-navigation/native'; +import React, { useEffect, useState } from 'react'; +import { useRoute } from '@react-navigation/native'; import BigNumber from 'bignumber.js'; import * as bitcoin from 'bitcoinjs-lib'; -import React, { useContext, useEffect, useState } from 'react'; import { FlatList, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { Icon } from 'react-native-elements'; import { satoshiToBTC, satoshiToLocalCurrency } from '../../blue_modules/currency'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueCard, BlueText } from '../../BlueComponents'; import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; @@ -14,6 +13,8 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; const shortenAddress = addr => { return addr.substr(0, Math.floor(addr.length / 2) - 1) + '\n' + addr.substr(Math.floor(addr.length / 2) - 1, addr.length); @@ -21,7 +22,7 @@ const shortenAddress = addr => { const PsbtMultisig = () => { const { wallets } = useStorage(); - const { navigate, setParams } = useNavigation(); + const { navigate, setParams } = useExtendedNavigation(); const { colors } = useTheme(); const [flatListHeight, setFlatListHeight] = useState(0); const { walletID, psbtBase64, memo, receivedPSBTBase64, launchedBy } = useRoute().params; diff --git a/screen/settings/Currency.tsx b/screen/settings/Currency.tsx index b2ea446fd0..dd42b57672 100644 --- a/screen/settings/Currency.tsx +++ b/screen/settings/Currency.tsx @@ -12,12 +12,12 @@ import { } from '../../blue_modules/currency'; import { BlueCard, BlueSpacing10, BlueText } from '../../BlueComponents'; import presentAlert from '../../components/Alert'; -import { useSettings } from '../../components/Context/SettingsContext'; import ListItem from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc from '../../loc'; import { FiatUnit, FiatUnitSource, FiatUnitType, getFiatRate } from '../../models/fiatUnit'; +import { useSettings } from '../../hooks/context/useSettings'; dayjs.extend(calendar); diff --git a/screen/settings/DefaultView.tsx b/screen/settings/DefaultView.tsx index f512a338da..b20afd87cd 100644 --- a/screen/settings/DefaultView.tsx +++ b/screen/settings/DefaultView.tsx @@ -2,13 +2,12 @@ import { useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import React, { useEffect, useReducer } from 'react'; import { ScrollView, TouchableWithoutFeedback, View } from 'react-native'; - -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueText } from '../../BlueComponents'; import { TWallet } from '../../class/wallets/types'; import ListItem from '../../components/ListItem'; import useOnAppLaunch from '../../hooks/useOnAppLaunch'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; type RootStackParamList = { SelectWallet: { onWalletSelect: (wallet: TWallet) => void; onChainRequireSend: boolean }; diff --git a/screen/settings/EncryptStorage.tsx b/screen/settings/EncryptStorage.tsx index 2f2e466523..8b041ee22f 100644 --- a/screen/settings/EncryptStorage.tsx +++ b/screen/settings/EncryptStorage.tsx @@ -3,7 +3,6 @@ import { Alert, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, Toucha import { StackActions } from '@react-navigation/native'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents'; import presentAlert from '../../components/Alert'; import ListItem from '../../components/ListItem'; @@ -12,6 +11,7 @@ import prompt from '../../helpers/prompt'; import { useBiometrics } from '../../hooks/useBiometrics'; import loc from '../../loc'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; +import { useStorage } from '../../hooks/context/useStorage'; enum ActionType { SetLoading = 'SET_LOADING', diff --git a/screen/settings/GeneralSettings.tsx b/screen/settings/GeneralSettings.tsx index 5f6473e5da..fd24fde36c 100644 --- a/screen/settings/GeneralSettings.tsx +++ b/screen/settings/GeneralSettings.tsx @@ -1,13 +1,12 @@ import { useNavigation } from '@react-navigation/native'; import React from 'react'; import { Platform, ScrollView, StyleSheet } from 'react-native'; - -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents'; -import { useSettings } from '../../components/Context/SettingsContext'; import ListItem, { PressableWrapper } from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useSettings } from '../../hooks/context/useSettings'; const styles = StyleSheet.create({ root: { diff --git a/screen/settings/Language.tsx b/screen/settings/Language.tsx index 09d48c67b2..66309b6e64 100644 --- a/screen/settings/Language.tsx +++ b/screen/settings/Language.tsx @@ -1,13 +1,12 @@ import React, { useEffect, useLayoutEffect, useState } from 'react'; import { FlatList, NativeSyntheticEvent, StyleSheet } from 'react-native'; - import presentAlert from '../../components/Alert'; -import { useSettings } from '../../components/Context/SettingsContext'; import ListItem from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc from '../../loc'; import { AvailableLanguages, TLanguage } from '../../loc/languages'; +import { useSettings } from '../../hooks/context/useSettings'; const Language = () => { const { setLanguageStorage, language } = useSettings(); diff --git a/screen/settings/Settings.js b/screen/settings/Settings.js index 0e37612e5e..87833e54d5 100644 --- a/screen/settings/Settings.js +++ b/screen/settings/Settings.js @@ -1,11 +1,10 @@ import React from 'react'; import { Platform, ScrollView, StyleSheet } from 'react-native'; - -import { useSettings } from '../../components/Context/SettingsContext'; import { Header } from '../../components/Header'; import ListItem from '../../components/ListItem'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc from '../../loc'; +import { useSettings } from '../../hooks/context/useSettings'; const styles = StyleSheet.create({ root: { diff --git a/screen/settings/SettingsPrivacy.tsx b/screen/settings/SettingsPrivacy.tsx index a92e009e3f..819858fcfd 100644 --- a/screen/settings/SettingsPrivacy.tsx +++ b/screen/settings/SettingsPrivacy.tsx @@ -1,16 +1,15 @@ -import React, { useContext, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Platform, Pressable, ScrollView, StyleSheet, Text, TouchableWithoutFeedback, View } from 'react-native'; import { openSettings } from 'react-native-permissions'; - import A from '../../blue_modules/analytics'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueCard, BlueSpacing20, BlueSpacing40, BlueText } from '../../BlueComponents'; -import { useSettings } from '../../components/Context/SettingsContext'; import { Header } from '../../components/Header'; import ListItem from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import { setBalanceDisplayAllowed } from '../../components/WidgetCommunication'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useSettings } from '../../hooks/context/useSettings'; enum SettingsPrivacySection { None, diff --git a/screen/settings/about.js b/screen/settings/about.js index b39aa61420..23e4915ade 100644 --- a/screen/settings/about.js +++ b/screen/settings/about.js @@ -1,13 +1,10 @@ +import React from 'react'; import Clipboard from '@react-native-clipboard/clipboard'; -import { useNavigation } from '@react-navigation/native'; -import React, { useContext } from 'react'; import { Alert, Image, Linking, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, useWindowDimensions, View } from 'react-native'; import { getApplicationName, getBuildNumber, getBundleId, getUniqueIdSync, getVersion, hasGmsSync } from 'react-native-device-info'; import { Icon } from 'react-native-elements'; import Rate, { AndroidMarket } from 'react-native-rate'; - import A from '../../blue_modules/analytics'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueCard, BlueSpacing20, BlueTextCentered } from '../../BlueComponents'; import { HDSegwitBech32Wallet } from '../../class'; import presentAlert from '../../components/Alert'; @@ -15,11 +12,13 @@ import Button from '../../components/Button'; import ListItem from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import loc, { formatStringAddTwoWhiteSpaces } from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; const branch = require('../../current-branch.json'); const About = () => { - const { navigate } = useNavigation(); + const { navigate } = useExtendedNavigation(); const { colors } = useTheme(); const { width, height } = useWindowDimensions(); const { isElectrumDisabled } = useStorage(); diff --git a/screen/transactions/TransactionDetails.tsx b/screen/transactions/TransactionDetails.tsx index d7476b1c7c..530e5b3f5b 100644 --- a/screen/transactions/TransactionDetails.tsx +++ b/screen/transactions/TransactionDetails.tsx @@ -1,13 +1,11 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import Clipboard from '@react-native-clipboard/clipboard'; import { RouteProp, useFocusEffect, useRoute } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import assert from 'assert'; import dayjs from 'dayjs'; -import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react'; import { InteractionManager, Keyboard, Linking, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native'; - import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueCard, BlueLoading, BlueSpacing20, BlueText } from '../../BlueComponents'; import { Transaction, TWallet } from '../../class/wallets/types'; import presentAlert from '../../components/Alert'; @@ -20,6 +18,7 @@ import ToolTipMenu from '../../components/TooltipMenu'; import loc from '../../loc'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamList'; +import { useStorage } from '../../hooks/context/useStorage'; interface TransactionDetailsProps { route: RouteProp<{ params: { hash: string; walletID: string } }, 'params'>; diff --git a/screen/transactions/TransactionStatus.tsx b/screen/transactions/TransactionStatus.tsx index 90a341901e..6be28aa00d 100644 --- a/screen/transactions/TransactionStatus.tsx +++ b/screen/transactions/TransactionStatus.tsx @@ -3,10 +3,8 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import React, { useEffect, useLayoutEffect, useReducer, useRef } from 'react'; import { ActivityIndicator, BackHandler, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { Icon } from 'react-native-elements'; - import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueLoading, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents'; import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class'; import { Transaction } from '../../class/wallets/types'; @@ -19,6 +17,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc, { formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; enum ButtonStatus { Possible, diff --git a/screen/wallets/Add.tsx b/screen/wallets/Add.tsx index 00b6060a97..59090dbf85 100644 --- a/screen/wallets/Add.tsx +++ b/screen/wallets/Add.tsx @@ -1,6 +1,6 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; import { useNavigation } from '@react-navigation/native'; -import React, { useContext, useEffect, useReducer } from 'react'; +import React, { useEffect, useReducer } from 'react'; import { ActivityIndicator, Keyboard, @@ -17,7 +17,6 @@ import { import A from '../../blue_modules/analytics'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueButtonLink, BlueFormLabel, BlueSpacing20, BlueSpacing40, BlueText } from '../../BlueComponents'; import { BlueApp, @@ -29,13 +28,14 @@ import { } from '../../class'; import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; -import { useSettings } from '../../components/Context/SettingsContext'; import { LdkButton } from '../../components/LdkButton'; import ListItem from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import WalletButton from '../../components/WalletButton'; import loc from '../../loc'; import { Chain } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useSettings } from '../../hooks/context/useSettings'; enum ButtonSelected { // @ts-ignore: Return later to update @@ -123,7 +123,7 @@ const WalletsAdd: React.FC = () => { const entropyButtonText = state.entropyButtonText; // const colorScheme = useColorScheme(); - const { addWallet, saveToDisk, wallets } = useContext(BlueStorageContext); + const { addWallet, saveToDisk, wallets } = useStorage(); const { isAdvancedModeEnabled } = useSettings(); const { navigate, goBack, setOptions } = useNavigation(); const stylesHook = { diff --git a/screen/wallets/DrawerList.tsx b/screen/wallets/DrawerList.tsx index 134c13208e..f16e91ac65 100644 --- a/screen/wallets/DrawerList.tsx +++ b/screen/wallets/DrawerList.tsx @@ -1,15 +1,15 @@ import { DrawerContentScrollView } from '@react-navigation/drawer'; import { NavigationProp, ParamListBase, useIsFocused } from '@react-navigation/native'; -import React, { memo, useCallback, useContext, useEffect, useMemo, useReducer, useRef } from 'react'; +import React, { memo, useCallback, useEffect, useMemo, useReducer, useRef } from 'react'; import { FlatList, InteractionManager, LayoutAnimation, StyleSheet, ViewStyle } from 'react-native'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { TWallet } from '../../class/wallets/types'; import { Header } from '../../components/Header'; import { useTheme } from '../../components/themes'; import WalletsCarousel from '../../components/WalletsCarousel'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; enum WalletActionType { SetWallets = 'SET_WALLETS', diff --git a/screen/wallets/ExportMultisigCoordinationSetup.tsx b/screen/wallets/ExportMultisigCoordinationSetup.tsx index 0235e1e3bb..22b121721b 100644 --- a/screen/wallets/ExportMultisigCoordinationSetup.tsx +++ b/screen/wallets/ExportMultisigCoordinationSetup.tsx @@ -1,8 +1,6 @@ import { RouteProp, useFocusEffect, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useMemo, useReducer, useRef } from 'react'; +import React, { useCallback, useMemo, useReducer, useRef } from 'react'; import { ActivityIndicator, InteractionManager, ScrollView, StyleSheet, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing20, BlueText } from '../../BlueComponents'; import { TWallet } from '../../class/wallets/types'; import { DynamicQRCode } from '../../components/DynamicQRCode'; @@ -11,6 +9,7 @@ import { SquareButton } from '../../components/SquareButton'; import { useTheme } from '../../components/themes'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; type RootStackParamList = { ExportMultisigCoordinationSetup: { diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index da188c8926..3c2c9680f7 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -1,14 +1,12 @@ +import React, { useEffect, useMemo, useState } from 'react'; import Clipboard from '@react-native-clipboard/clipboard'; import { RouteProp, useRoute } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import assert from 'assert'; import createHash from 'create-hash'; -import React, { useEffect, useMemo, useState } from 'react'; import { SectionList, StyleSheet, Text, View } from 'react-native'; - import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import { satoshiToLocalCurrency } from '../../blue_modules/currency'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueButtonLink, BlueLoading } from '../../BlueComponents'; import { HDSegwitBech32Wallet } from '../../class'; import { ContactList } from '../../class/contact-list'; @@ -25,6 +23,7 @@ import { BitcoinUnit } from '../../models/bitcoinUnits'; import { PaymentCodeStackParamList } from '../../navigation/PaymentCodeStack'; import SafeArea from '../../components/SafeArea'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; +import { useStorage } from '../../hooks/context/useStorage'; interface DataSection { title: string; diff --git a/screen/wallets/PleaseBackup.tsx b/screen/wallets/PleaseBackup.tsx index 25ed9f1292..98e445cdf9 100644 --- a/screen/wallets/PleaseBackup.tsx +++ b/screen/wallets/PleaseBackup.tsx @@ -1,12 +1,11 @@ -import { useNavigation, useRoute } from '@react-navigation/native'; import React, { useCallback, useEffect } from 'react'; +import { useNavigation, useRoute } from '@react-navigation/native'; import { BackHandler, I18nManager, ScrollView, StyleSheet, Text, View } from 'react-native'; - -import { useStorage } from '../../blue_modules/storage-context'; import Button from '../../components/Button'; import { useTheme } from '../../components/themes'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const PleaseBackup: React.FC = () => { const { wallets } = useStorage(); diff --git a/screen/wallets/ViewEditMultisigCosigners.tsx b/screen/wallets/ViewEditMultisigCosigners.tsx index 8bedb8b3ae..16402eaba2 100644 --- a/screen/wallets/ViewEditMultisigCosigners.tsx +++ b/screen/wallets/ViewEditMultisigCosigners.tsx @@ -1,5 +1,5 @@ -import { useFocusEffect, useRoute } from '@react-navigation/native'; import React, { useCallback, useRef, useState } from 'react'; +import { useFocusEffect, useRoute } from '@react-navigation/native'; import { ActivityIndicator, Alert, @@ -17,9 +17,7 @@ import { View, } from 'react-native'; import { Badge, Icon } from 'react-native-elements'; - import { isDesktop, isTablet } from '../../blue_modules/environment'; -import { useStorage } from '../../blue_modules/storage-context'; import { encodeUR } from '../../blue_modules/ur'; import { BlueButtonLink, @@ -35,7 +33,6 @@ import { HDSegwitBech32Wallet, MultisigCosigner, MultisigHDWallet } from '../../ import presentAlert from '../../components/Alert'; import BottomModal from '../../components/BottomModal'; import Button from '../../components/Button'; -import { useSettings } from '../../components/Context/SettingsContext'; import MultipleStepsListItem, { MultipleStepsListItemButtohType, MultipleStepsListItemDashType, @@ -52,6 +49,8 @@ import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; import ActionSheet from '../ActionSheet'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useSettings } from '../../hooks/context/useSettings'; const ViewEditMultisigCosigners: React.FC = () => { const hasLoaded = useRef(false); diff --git a/screen/wallets/WalletsList.tsx b/screen/wallets/WalletsList.tsx index f629ee9e3e..55707529b0 100644 --- a/screen/wallets/WalletsList.tsx +++ b/screen/wallets/WalletsList.tsx @@ -1,13 +1,11 @@ -import { useFocusEffect, useIsFocused, useRoute } from '@react-navigation/native'; import React, { useCallback, useEffect, useReducer, useRef } from 'react'; +import { useFocusEffect, useIsFocused, useRoute } from '@react-navigation/native'; import { findNodeHandle, Image, InteractionManager, SectionList, StyleSheet, Text, useWindowDimensions, View } from 'react-native'; - import A from '../../blue_modules/analytics'; import BlueClipboard from '../../blue_modules/clipboard'; import { isDesktop } from '../../blue_modules/environment'; import * as fs from '../../blue_modules/fs'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage } from '../../blue_modules/storage-context'; import DeeplinkSchemaMatch from '../../class/deeplink-schema-match'; import { ExtendedTransaction, Transaction, TWallet } from '../../class/wallets/types'; import presentAlert from '../../components/Alert'; @@ -23,6 +21,7 @@ import ActionSheet from '../ActionSheet'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { DetailViewStackParamList } from '../../navigation/DetailViewStackParamList'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; +import { useStorage } from '../../hooks/context/useStorage'; const WalletsListSections = { CAROUSEL: 'CAROUSEL', TRANSACTIONS: 'TRANSACTIONS' }; diff --git a/screen/wallets/addMultisig.js b/screen/wallets/addMultisig.js index e4829b4966..f7e2d8aad1 100644 --- a/screen/wallets/addMultisig.js +++ b/screen/wallets/addMultisig.js @@ -8,11 +8,11 @@ import { BlueSpacing20 } from '../../BlueComponents'; import { MultisigHDWallet } from '../../class'; import BottomModal from '../../components/BottomModal'; import Button from '../../components/Button'; -import { useSettings } from '../../components/Context/SettingsContext'; import ListItem from '../../components/ListItem'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; +import { useSettings } from '../../hooks/context/useSettings'; const WalletsAddMultisig = () => { const { colors } = useTheme(); diff --git a/screen/wallets/addMultisigStep2.js b/screen/wallets/addMultisigStep2.js index d5c0759faa..8b1a98ae1d 100644 --- a/screen/wallets/addMultisigStep2.js +++ b/screen/wallets/addMultisigStep2.js @@ -1,5 +1,5 @@ import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { ActivityIndicator, FlatList, @@ -19,14 +19,12 @@ import { Icon } from 'react-native-elements'; import A from '../../blue_modules/analytics'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { encodeUR } from '../../blue_modules/ur'; import { BlueButtonLink, BlueFormMultiInput, BlueSpacing10, BlueSpacing20, BlueText, BlueTextCentered } from '../../BlueComponents'; import { HDSegwitBech32Wallet, MultisigCosigner, MultisigHDWallet } from '../../class'; import presentAlert from '../../components/Alert'; import BottomModal from '../../components/BottomModal'; import Button from '../../components/Button'; -import { useSettings } from '../../components/Context/SettingsContext'; import MultipleStepsListItem, { MultipleStepsListItemButtohType, MultipleStepsListItemDashType, @@ -40,6 +38,8 @@ import prompt from '../../helpers/prompt'; import { scanQrHelper } from '../../helpers/scan-qr'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useSettings } from '../../hooks/context/useSettings'; const staticCache = {}; diff --git a/screen/wallets/addresses.js b/screen/wallets/addresses.js index 633e92388b..8e189fed60 100644 --- a/screen/wallets/addresses.js +++ b/screen/wallets/addresses.js @@ -1,8 +1,6 @@ import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'; import { ActivityIndicator, FlatList, StyleSheet, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { WatchOnlyWallet } from '../../class'; import { AddressItem } from '../../components/addresses/AddressItem'; import { AddressTypeTabs, TABS } from '../../components/addresses/AddressTypeTabs'; @@ -10,6 +8,7 @@ import navigationStyle from '../../components/navigationStyle'; import { useTheme } from '../../components/themes'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; export const totalBalance = ({ c, u } = { c: 0, u: 0 }) => c + u; diff --git a/screen/wallets/details.js b/screen/wallets/details.js index a8b2367463..0036ecc592 100644 --- a/screen/wallets/details.js +++ b/screen/wallets/details.js @@ -37,7 +37,6 @@ import { AbstractHDElectrumWallet } from '../../class/wallets/abstract-hd-electr import { LightningCustodianWallet } from '../../class/wallets/lightning-custodian-wallet'; import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; -import { useSettings } from '../../components/Context/SettingsContext'; import HeaderRightButton from '../../components/HeaderRightButton'; import ListItem from '../../components/ListItem'; import SaveFileButton from '../../components/SaveFileButton'; @@ -48,6 +47,7 @@ import { useBiometrics } from '../../hooks/useBiometrics'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc, { formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; +import { useSettings } from '../../hooks/context/useSettings'; const styles = StyleSheet.create({ scrollViewContent: { diff --git a/screen/wallets/export.js b/screen/wallets/export.js index 18902bd78b..e67ce9cb93 100644 --- a/screen/wallets/export.js +++ b/screen/wallets/export.js @@ -1,8 +1,6 @@ import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; import { ActivityIndicator, AppState, InteractionManager, ScrollView, StyleSheet, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents'; import { LegacyWallet, LightningCustodianWallet, SegwitBech32Wallet, SegwitP2SHWallet, WatchOnlyWallet } from '../../class'; import CopyTextToClipboard from '../../components/CopyTextToClipboard'; @@ -12,6 +10,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const WalletExport = () => { const { wallets, saveToDisk } = useStorage(); diff --git a/screen/wallets/import.js b/screen/wallets/import.js index 972c80ace0..a260225012 100644 --- a/screen/wallets/import.js +++ b/screen/wallets/import.js @@ -11,12 +11,12 @@ import { BlueText, } from '../../BlueComponents'; import Button from '../../components/Button'; -import { useSettings } from '../../components/Context/SettingsContext'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useSettings } from '../../hooks/context/useSettings'; const WalletsImport = () => { const navigation = useNavigation(); diff --git a/screen/wallets/importCustomDerivationPath.js b/screen/wallets/importCustomDerivationPath.js index f1f2d77d7b..70120eddb6 100644 --- a/screen/wallets/importCustomDerivationPath.js +++ b/screen/wallets/importCustomDerivationPath.js @@ -1,9 +1,7 @@ import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useContext, useEffect, useMemo, useRef, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import { FlatList, StyleSheet, TextInput, View } from 'react-native'; - import debounce from '../../blue_modules/debounce'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueFormLabel, BlueSpacing20, BlueTextCentered } from '../../BlueComponents'; import { HDLegacyP2PKHWallet, HDSegwitBech32Wallet, HDSegwitP2SHWallet } from '../../class'; import { validateBip32 } from '../../class/wallet-import'; @@ -13,6 +11,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import WalletToImport from '../../components/WalletToImport'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const WRONG_PATH = 'WRONG_PATH'; const WALLET_FOUND = 'WALLET_FOUND'; diff --git a/screen/wallets/importDiscovery.js b/screen/wallets/importDiscovery.js index 177f057806..b3cba6c72f 100644 --- a/screen/wallets/importDiscovery.js +++ b/screen/wallets/importDiscovery.js @@ -1,10 +1,8 @@ -import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useContext, useEffect, useMemo, useRef, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; +import { useRoute } from '@react-navigation/native'; import { ActivityIndicator, FlatList, LayoutAnimation, StyleSheet, View } from 'react-native'; import IdleTimerManager from 'react-native-idle-timer'; - import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueButtonLink, BlueFormLabel, BlueSpacing10, BlueSpacing20 } from '../../BlueComponents'; import { HDSegwitBech32Wallet } from '../../class'; import startImport from '../../class/wallet-import'; @@ -15,9 +13,11 @@ import { useTheme } from '../../components/themes'; import WalletToImport from '../../components/WalletToImport'; import prompt from '../../helpers/prompt'; import loc from '../../loc'; +import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; +import { useStorage } from '../../hooks/context/useStorage'; const ImportWalletDiscovery = () => { - const navigation = useNavigation(); + const navigation = useExtendedNavigation(); const { colors } = useTheme(); const route = useRoute(); const { importText, askPassphrase, searchAccounts } = route.params; diff --git a/screen/wallets/importSpeed.js b/screen/wallets/importSpeed.js index 4304c98a0d..cb054c51ec 100644 --- a/screen/wallets/importSpeed.js +++ b/screen/wallets/importSpeed.js @@ -1,14 +1,13 @@ import { useNavigation } from '@react-navigation/native'; -import React, { useContext, useState } from 'react'; +import React, { useState } from 'react'; import { ActivityIndicator, StyleSheet, TextInput, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueFormLabel, BlueFormMultiInput, BlueSpacing20 } from '../../BlueComponents'; import { HDSegwitBech32Wallet, WatchOnlyWallet } from '../../class'; import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; +import { useStorage } from '../../hooks/context/useStorage'; const WalletsImportWallet = () => { const navigation = useNavigation(); diff --git a/screen/wallets/ldkViewLogs.js b/screen/wallets/ldkViewLogs.js index 038fd9128e..f3f47452f0 100644 --- a/screen/wallets/ldkViewLogs.js +++ b/screen/wallets/ldkViewLogs.js @@ -1,10 +1,8 @@ import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useContext, useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { ScrollView, StyleSheet, TouchableOpacity, View } from 'react-native'; import { Icon } from 'react-native-elements'; - import * as fs from '../../blue_modules/fs'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueLoading, BlueSpacing20, BlueText } from '../../BlueComponents'; import { LightningLdkWallet } from '../../class'; import presentAlert from '../../components/Alert'; @@ -12,6 +10,7 @@ import navigationStyle from '../../components/navigationStyle'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const LdkViewLogs = () => { const { colors } = useTheme(); diff --git a/screen/wallets/pleaseBackupLNDHub.js b/screen/wallets/pleaseBackupLNDHub.js index 0459209db5..f20802ddbd 100644 --- a/screen/wallets/pleaseBackupLNDHub.js +++ b/screen/wallets/pleaseBackupLNDHub.js @@ -1,8 +1,6 @@ import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { BackHandler, ScrollView, StyleSheet, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing20, BlueTextCentered } from '../../BlueComponents'; import Button from '../../components/Button'; import CopyTextToClipboard from '../../components/CopyTextToClipboard'; @@ -11,6 +9,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const PleaseBackupLNDHub = () => { const { wallets } = useStorage(); diff --git a/screen/wallets/pleaseBackupLdk.js b/screen/wallets/pleaseBackupLdk.js index 88746be5b4..336541bc93 100644 --- a/screen/wallets/pleaseBackupLdk.js +++ b/screen/wallets/pleaseBackupLdk.js @@ -1,9 +1,7 @@ +import React, { useCallback, useEffect } from 'react'; import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useCallback, useContext, useEffect } from 'react'; import { BackHandler, ScrollView, StyleSheet, useWindowDimensions, View } from 'react-native'; import QRCode from 'react-native-qrcode-svg'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing20, BlueTextCentered } from '../../BlueComponents'; import Button from '../../components/Button'; import CopyTextToClipboard from '../../components/CopyTextToClipboard'; @@ -11,6 +9,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const PleaseBackupLdk = () => { const { wallets } = useStorage(); diff --git a/screen/wallets/reorderWallets.js b/screen/wallets/reorderWallets.js index 8e199e4150..28cb29c874 100644 --- a/screen/wallets/reorderWallets.js +++ b/screen/wallets/reorderWallets.js @@ -1,14 +1,13 @@ -import React, { useContext, useEffect, useLayoutEffect, useRef, useState } from 'react'; +import React, { useEffect, useLayoutEffect, useRef, useState } from 'react'; import { Platform, StyleSheet, useColorScheme } from 'react-native'; import DraggableFlatList, { ScaleDecorator } from 'react-native-draggable-flatlist'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; - import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { useTheme } from '../../components/themes'; import { WalletCarouselItem } from '../../components/WalletsCarousel'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const styles = StyleSheet.create({ root: { diff --git a/screen/wallets/selectWallet.js b/screen/wallets/selectWallet.js index b47c30c117..78f67358a4 100644 --- a/screen/wallets/selectWallet.js +++ b/screen/wallets/selectWallet.js @@ -1,10 +1,8 @@ import { useNavigation, useNavigationState, useRoute } from '@react-navigation/native'; -import React, { useContext, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { ActivityIndicator, FlatList, I18nManager, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; - import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing20, BlueText } from '../../BlueComponents'; import { LightningCustodianWallet, LightningLdkWallet, MultisigHDWallet } from '../../class'; import WalletGradient from '../../class/wallet-gradient'; @@ -13,6 +11,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc, { formatBalance, transactionTimeToReadable } from '../../loc'; import { Chain } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; const SelectWallet = () => { const { chainType, onWalletSelect, availableWallets, noWalletExplanationText, onChainRequireSend = false } = useRoute().params; diff --git a/screen/wallets/signVerify.js b/screen/wallets/signVerify.js index 37eedcc42d..b25dee6f74 100644 --- a/screen/wallets/signVerify.js +++ b/screen/wallets/signVerify.js @@ -1,5 +1,5 @@ +import React, { useEffect, useState } from 'react'; import { useRoute } from '@react-navigation/native'; -import React, { useContext, useEffect, useState } from 'react'; import { ActivityIndicator, Keyboard, @@ -13,15 +13,14 @@ import { } from 'react-native'; import { Icon } from 'react-native-elements'; import Share from 'react-native-share'; - import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueDoneAndDismissKeyboardInputAccessory, BlueFormLabel, BlueSpacing10, BlueSpacing20, BlueSpacing40 } from '../../BlueComponents'; import presentAlert from '../../components/Alert'; import { FButton, FContainer } from '../../components/FloatButtons'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; const SignVerify = () => { const { colors } = useTheme(); From ed68a20b4ff30fccfa899eaad20862be5db77e34 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 13:22:22 -0400 Subject: [PATCH 005/114] REF: Continue renaming --- screen/lnd/lnurlPay.js | 8 ++++---- screen/lnd/scanLndInvoice.js | 2 +- screen/receive/aztecoRedeem.js | 5 ++--- screen/send/isItMyAddress.js | 12 ++++++------ screen/send/psbtWithHardwareWallet.js | 9 ++++----- screen/settings/electrumSettings.js | 5 ++--- screen/transactions/CPFP.js | 9 ++++----- screen/transactions/RBFBumpFee.js | 7 +++---- screen/transactions/RBFCancel.js | 7 +++---- screen/wallets/details.js | 5 ++--- screen/wallets/transactions.js | 3 ++- 11 files changed, 33 insertions(+), 39 deletions(-) diff --git a/screen/lnd/lnurlPay.js b/screen/lnd/lnurlPay.js index 375d0e9472..5f718b70fd 100644 --- a/screen/lnd/lnurlPay.js +++ b/screen/lnd/lnurlPay.js @@ -1,12 +1,10 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; -import { useNavigation, useRoute } from '@react-navigation/native'; +import { useRoute } from '@react-navigation/native'; import React, { useEffect, useState } from 'react'; import { I18nManager, Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { Icon } from 'react-native-elements'; - import { btcToSatoshi, fiatToBTC, satoshiToBTC, satoshiToLocalCurrency } from '../../blue_modules/currency'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueDismissKeyboardInputAccessory, BlueLoading, BlueSpacing20, BlueText } from '../../BlueComponents'; import Lnurl from '../../class/lnurl'; import presentAlert from '../../components/Alert'; @@ -18,6 +16,8 @@ import prompt from '../../helpers/prompt'; import { useBiometrics } from '../../hooks/useBiometrics'; import loc, { formatBalance, formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; /** * if user has default currency - fiat, attempting to pay will trigger conversion from entered in input field fiat value @@ -37,7 +37,7 @@ const LnurlPay = () => { const [_LN, setLN] = useState(); const [payButtonDisabled, setPayButtonDisabled] = useState(true); const [payload, setPayload] = useState(); - const { setParams, pop, navigate } = useNavigation(); + const { setParams, pop, navigate } = useExtendedNavigation(); const [amount, setAmount] = useState(); const { colors } = useTheme(); const stylesHook = StyleSheet.create({ diff --git a/screen/lnd/scanLndInvoice.js b/screen/lnd/scanLndInvoice.js index 85b76c87b0..edb69f6a9f 100644 --- a/screen/lnd/scanLndInvoice.js +++ b/screen/lnd/scanLndInvoice.js @@ -15,7 +15,6 @@ import { Icon } from 'react-native-elements'; import { btcToSatoshi, fiatToBTC } from '../../blue_modules/currency'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueDismissKeyboardInputAccessory, BlueLoading } from '../../BlueComponents'; import Lnurl from '../../class/lnurl'; import AddressInput from '../../components/AddressInput'; @@ -27,6 +26,7 @@ import { useTheme } from '../../components/themes'; import { useBiometrics } from '../../hooks/useBiometrics'; import loc, { formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; +import { useStorage } from '../../hooks/context/useStorage'; const ScanLndInvoice = () => { const { wallets, fetchAndSaveWalletTransactions } = useStorage(); diff --git a/screen/receive/aztecoRedeem.js b/screen/receive/aztecoRedeem.js index 6f67e94749..1309d2ac05 100644 --- a/screen/receive/aztecoRedeem.js +++ b/screen/receive/aztecoRedeem.js @@ -2,13 +2,12 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { I18nManager, Keyboard, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native'; import { Icon } from 'react-native-elements'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueLoading, BlueSpacing, BlueText } from '../../BlueComponents'; import Azteco from '../../class/azteco'; import presentAlert from '../../components/Alert'; import Button from '../../components/Button'; import loc from '../../loc'; +import { StorageContext } from '../../components/Context/StorageProvider'; const styles = StyleSheet.create({ loading: { @@ -51,7 +50,7 @@ const styles = StyleSheet.create({ }); export default class AztecoRedeem extends Component { - static contextType = BlueStorageContext; + static contextType = StorageContext; state = { isLoading: true }; constructor(props, context) { diff --git a/screen/send/isItMyAddress.js b/screen/send/isItMyAddress.js index 96167b26a7..79b250a28e 100644 --- a/screen/send/isItMyAddress.js +++ b/screen/send/isItMyAddress.js @@ -1,8 +1,6 @@ -import { useNavigation, useRoute } from '@react-navigation/native'; -import React, { useContext, useRef, useState } from 'react'; +import React, { useRef, useState } from 'react'; +import { useRoute } from '@react-navigation/native'; import { Keyboard, KeyboardAvoidingView, Platform, StyleSheet, TextInput, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueButtonLink, BlueCard, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents'; import Button from '../../components/Button'; import navigationStyle from '../../components/navigationStyle'; @@ -10,11 +8,13 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; const IsItMyAddress = () => { /** @type {AbstractWallet[]} */ - const wallets = useContext(BlueStorageContext).wallets; - const { navigate } = useNavigation(); + const { wallets } = useStorage(); + const { navigate } = useExtendedNavigation(); const { name } = useRoute(); const { colors } = useTheme(); const scanButtonRef = useRef(); diff --git a/screen/send/psbtWithHardwareWallet.js b/screen/send/psbtWithHardwareWallet.js index 569ff4772d..a4df92baa6 100644 --- a/screen/send/psbtWithHardwareWallet.js +++ b/screen/send/psbtWithHardwareWallet.js @@ -1,15 +1,13 @@ import Clipboard from '@react-native-clipboard/clipboard'; -import { useIsFocused, useNavigation, useRoute } from '@react-navigation/native'; +import { useIsFocused, useRoute } from '@react-navigation/native'; import * as bitcoin from 'bitcoinjs-lib'; import React, { useEffect, useRef, useState } from 'react'; import { ActivityIndicator, Linking, Platform, ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'; import DocumentPicker from 'react-native-document-picker'; import RNFS from 'react-native-fs'; - import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import Notifications from '../../blue_modules/notifications'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents'; import presentAlert from '../../components/Alert'; import CopyToClipboardButton from '../../components/CopyToClipboardButton'; @@ -20,12 +18,13 @@ import { useTheme } from '../../components/themes'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; import { useBiometrics } from '../../hooks/useBiometrics'; import loc from '../../loc'; +import { useStorage } from '../../hooks/context/useStorage'; +import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; const PsbtWithHardwareWallet = () => { const { txMetadata, fetchAndSaveWalletTransactions, isElectrumDisabled } = useStorage(); const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); - - const navigation = useNavigation(); + const navigation = useExtendedNavigation(); const route = useRoute(); const { fromWallet, memo, psbt, deepLinkPSBT, launchedBy } = route.params; const routeParamsPSBT = useRef(route.params.psbt); diff --git a/screen/settings/electrumSettings.js b/screen/settings/electrumSettings.js index 93a1303282..7939a44b3b 100644 --- a/screen/settings/electrumSettings.js +++ b/screen/settings/electrumSettings.js @@ -16,10 +16,8 @@ import { View, } from 'react-native'; import DefaultPreference from 'react-native-default-preference'; - import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueButtonLink, BlueCard, @@ -36,9 +34,10 @@ import ListItem from '../../components/ListItem'; import { BlueCurrentTheme } from '../../components/themes'; import { scanQrHelper } from '../../helpers/scan-qr'; import loc from '../../loc'; +import { StorageContext } from '../../components/Context/StorageProvider'; export default class ElectrumSettings extends Component { - static contextType = BlueStorageContext; + static contextType = StorageContext; constructor(props) { super(props); const server = props?.route?.params?.server; diff --git a/screen/transactions/CPFP.js b/screen/transactions/CPFP.js index b388325852..557465f13c 100644 --- a/screen/transactions/CPFP.js +++ b/screen/transactions/CPFP.js @@ -1,5 +1,3 @@ -import Clipboard from '@react-native-clipboard/clipboard'; -import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { ActivityIndicator, @@ -12,12 +10,12 @@ import { TouchableOpacity, View, } from 'react-native'; +import Clipboard from '@react-native-clipboard/clipboard'; +import PropTypes from 'prop-types'; import { Text } from 'react-native-elements'; - import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import Notifications from '../../blue_modules/notifications'; -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueCard, BlueReplaceFeeSuggestions, BlueSpacing, BlueSpacing20, BlueText } from '../../BlueComponents'; import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class'; import presentAlert from '../../components/Alert'; @@ -26,6 +24,7 @@ import navigationStyle from '../../components/navigationStyle'; import SafeArea from '../../components/SafeArea'; import { BlueCurrentTheme } from '../../components/themes'; import loc from '../../loc'; +import { StorageContext } from '../../components/Context/StorageProvider'; const styles = StyleSheet.create({ root: { @@ -67,7 +66,7 @@ const styles = StyleSheet.create({ }); export default class CPFP extends Component { - static contextType = BlueStorageContext; + static contextType = StorageContext; constructor(props) { super(props); let txid; diff --git a/screen/transactions/RBFBumpFee.js b/screen/transactions/RBFBumpFee.js index 965e9434b4..a09e688b75 100644 --- a/screen/transactions/RBFBumpFee.js +++ b/screen/transactions/RBFBumpFee.js @@ -1,8 +1,6 @@ -import PropTypes from 'prop-types'; import React from 'react'; +import PropTypes from 'prop-types'; import { ActivityIndicator, ScrollView, StyleSheet, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing20, BlueText } from '../../BlueComponents'; import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class'; import presentAlert from '../../components/Alert'; @@ -10,6 +8,7 @@ import navigationStyle from '../../components/navigationStyle'; import SafeArea from '../../components/SafeArea'; import loc from '../../loc'; import CPFP from './CPFP'; +import { StorageContext } from '../../components/Context/StorageProvider'; const styles = StyleSheet.create({ root: { @@ -19,7 +18,7 @@ const styles = StyleSheet.create({ }); export default class RBFBumpFee extends CPFP { - static contextType = BlueStorageContext; + static contextType = StorageContext; async componentDidMount() { console.log('transactions/RBFBumpFee - componentDidMount'); diff --git a/screen/transactions/RBFCancel.js b/screen/transactions/RBFCancel.js index c3beed89db..38f8ea291f 100644 --- a/screen/transactions/RBFCancel.js +++ b/screen/transactions/RBFCancel.js @@ -1,8 +1,6 @@ -import PropTypes from 'prop-types'; import React from 'react'; +import PropTypes from 'prop-types'; import { ActivityIndicator, ScrollView, View } from 'react-native'; - -import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueSpacing20, BlueText } from '../../BlueComponents'; import { HDSegwitBech32Transaction, HDSegwitBech32Wallet } from '../../class'; import presentAlert from '../../components/Alert'; @@ -10,9 +8,10 @@ import navigationStyle from '../../components/navigationStyle'; import SafeArea from '../../components/SafeArea'; import loc from '../../loc'; import CPFP from './CPFP'; +import { StorageContext } from '../../components/Context/StorageProvider'; export default class RBFCancel extends CPFP { - static contextType = BlueStorageContext; + static contextType = StorageContext; async componentDidMount() { console.log('transactions/RBFCancel - componentDidMount'); this.setState({ diff --git a/screen/wallets/details.js b/screen/wallets/details.js index 0036ecc592..7643cdabc8 100644 --- a/screen/wallets/details.js +++ b/screen/wallets/details.js @@ -1,5 +1,5 @@ -import { useRoute } from '@react-navigation/native'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { useRoute } from '@react-navigation/native'; import { ActivityIndicator, Alert, @@ -17,11 +17,9 @@ import { TouchableWithoutFeedback, View, } from 'react-native'; - import { writeFileAndExport } from '../../blue_modules/fs'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import Notifications from '../../blue_modules/notifications'; -import { useStorage } from '../../blue_modules/storage-context'; import { BlueCard, BlueLoading, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents'; import { HDAezeedWallet, @@ -48,6 +46,7 @@ import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc, { formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import { useSettings } from '../../hooks/context/useSettings'; +import { useStorage } from '../../hooks/context/useStorage'; const styles = StyleSheet.create({ scrollViewContent: { diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index eacb9dff3e..4c0b2e6c32 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -24,7 +24,6 @@ import BlueClipboard from '../../blue_modules/clipboard'; import { isDesktop } from '../../blue_modules/environment'; import * as fs from '../../blue_modules/fs'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; -import { useStorage, WalletTransactionsStatus } from '../../blue_modules/storage-context'; import { LightningCustodianWallet, LightningLdkWallet, MultisigHDWallet, WatchOnlyWallet } from '../../class'; import WalletGradient from '../../class/wallet-gradient'; import presentAlert from '../../components/Alert'; @@ -41,6 +40,8 @@ import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc from '../../loc'; import { Chain } from '../../models/bitcoinUnits'; import ActionSheet from '../ActionSheet'; +import { useStorage } from '../../hooks/context/useStorage'; +import { WalletTransactionsStatus } from '../../components/Context/StorageProvider'; const buttonFontSize = PixelRatio.roundToNearestPixel(Dimensions.get('window').width / 26) > 22 From 4dab9c24e12774089ae167730b2872b043783722 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 13:23:50 -0400 Subject: [PATCH 006/114] Update WalletsCarousel.js --- components/WalletsCarousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/WalletsCarousel.js b/components/WalletsCarousel.js index e6ffd09b29..a8dda48a98 100644 --- a/components/WalletsCarousel.js +++ b/components/WalletsCarousel.js @@ -20,7 +20,7 @@ import WalletGradient from '../class/wallet-gradient'; import { useIsLargeScreen } from '../hooks/useIsLargeScreen'; import loc, { formatBalance, transactionTimeToReadable } from '../loc'; import { BlurredBalanceView } from './BlurredBalanceView'; -import { useSettings } from '../../hooks/context/useSettings'; +import { useSettings } from '../hooks/context/useSettings'; import { useTheme } from './themes'; import { useStorage } from '../hooks/context/useStorage'; import { WalletTransactionsStatus } from './Context/StorageProvider'; From 1cffbf269638c20cd9738e285dcfc627f5b95e1b Mon Sep 17 00:00:00 2001 From: overtorment Date: Fri, 31 May 2024 20:59:03 +0100 Subject: [PATCH 007/114] REF: silent-payments minor refactor --- class/wallets/abstract-hd-electrum-wallet.ts | 31 +++++--------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/class/wallets/abstract-hd-electrum-wallet.ts b/class/wallets/abstract-hd-electrum-wallet.ts index 0d8a68d726..f430c7e7a0 100644 --- a/class/wallets/abstract-hd-electrum-wallet.ts +++ b/class/wallets/abstract-hd-electrum-wallet.ts @@ -17,7 +17,7 @@ import ecc from '../../blue_modules/noble_ecc'; import { randomBytes } from '../rng'; import { AbstractHDWallet } from './abstract-hd-wallet'; import { CreateTransactionResult, CreateTransactionTarget, CreateTransactionUtxo, Transaction, Utxo } from './types'; -import { SilentPayment } from 'silent-payments'; +import { SilentPayment, UTXOType as SPUTXOType, UTXO as SPUTXO } from 'silent-payments'; const ECPair = ECPairFactory(ecc); const bip32 = BIP32Factory(ecc); @@ -1185,22 +1185,14 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { let { inputs, outputs, fee } = this.coinselect(utxos, targets, feeRate); - let hasSilentPaymentOutput = false; - outputs.map(o => { - if (o.address?.startsWith('sp1')) hasSilentPaymentOutput = true; - return null; // because map func demands to return at least something - }); - + const hasSilentPaymentOutput: boolean = !!outputs.find(o => o.address?.startsWith('sp1')); if (hasSilentPaymentOutput) { if (!this.allowSilentPaymentSend()) { throw new Error('This wallet can not send to SilentPayment address'); } - // doing a clone of coinselected UTXOs: - const spUtxos: any[] = []; - // for a single wallet all utxos gona be the same type, so we define it only once: - let utxoType: string = 'non-eligible'; + let utxoType: SPUTXOType = 'non-eligible'; switch (this.segwitType) { case 'p2sh(p2wpkh)': utxoType = 'p2sh-p2wpkh'; @@ -1208,20 +1200,12 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { case 'p2wpkh': utxoType = 'p2wpkh'; break; + default: + // @ts-ignore override + if (this.type === 'HDlegacyP2PKH') utxoType = 'p2pkh'; } - // @ts-ignore override - if (this.type === 'HDlegacyP2PKH') utxoType = 'p2pkh'; - - inputs.map(u => - spUtxos.push({ - txid: u.txid, - vout: u.vout, - wif: u.wif, - utxoType, - }), - ); - + const spUtxos: SPUTXO[] = inputs.map(u => ({ ...u, utxoType, wif: u.wif! })); const sp = new SilentPayment(); outputs = sp.createTransaction(spUtxos, outputs) as CoinSelectOutput[]; } @@ -1289,6 +1273,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { if (output.address?.startsWith('PM')) { // ok its BIP47 payment code, so we need to unwrap a joint address for the receiver and use it instead: output.address = this._getNextFreePaymentCodeAddressSend(output.address); + // ^^^ trusting that notification transaction is in place } psbt.addOutput({ From 14cbdae1c13023889fb2bdb1460a5dd12bca809b Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 17:31:12 -0400 Subject: [PATCH 008/114] Update Podfile.lock --- ios/Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 23c863b2ea..a856adca80 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -345,7 +345,7 @@ PODS: - React - react-native-randombytes (3.6.1): - React-Core - - react-native-safe-area-context (4.10.1): + - react-native-safe-area-context (4.10.3): - React-Core - react-native-secure-key-store (2.0.10): - React-Core @@ -809,7 +809,7 @@ SPEC CHECKSUMS: react-native-ios-context-menu: e529171ba760a1af7f2ef0729f5a7f4d226171c5 react-native-qrcode-local-image: 35ccb306e4265bc5545f813e54cc830b5d75bcfc react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846 - react-native-safe-area-context: dcab599c527c2d7de2d76507a523d20a0b83823d + react-native-safe-area-context: b01d8f42d4e62a7be5a3e69fd332e0c7e67584c7 react-native-secure-key-store: 910e6df6bc33cb790aba6ee24bc7818df1fe5898 react-native-tcp-socket: e724380c910c2e704816ec817ed28f1342246ff7 React-NativeModulesApple: 3107f777453f953906d9ba9dc5f8cbd91a6ef913 From c41d8314e1789423a0a9ef2a6093b9948a69e8b8 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 19:50:48 -0400 Subject: [PATCH 009/114] FIX: Notification toggle was stopped by an undefined object --- blue_modules/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blue_modules/notifications.js b/blue_modules/notifications.js index 411f8fae72..8a77a3d022 100644 --- a/blue_modules/notifications.js +++ b/blue_modules/notifications.js @@ -152,7 +152,7 @@ function Notifications(props) { message: loc.notifications.would_you_like_to_receive_notifications, options, cancelButtonIndex: 0, // Assuming 'no and don't ask' is still treated as the cancel action - anchor: findNodeHandle(anchor.current), + anchor: anchor ? findNodeHandle(anchor.current) : undefined, }, buttonIndex => { switch (buttonIndex) { From 8c68b001207333135ce71fdb76428ee1f8fc6720 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Fri, 31 May 2024 19:52:40 -0400 Subject: [PATCH 010/114] Update ActionSheet.ios.ts --- screen/ActionSheet.ios.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/screen/ActionSheet.ios.ts b/screen/ActionSheet.ios.ts index ad542c6dde..d068b3b6b5 100644 --- a/screen/ActionSheet.ios.ts +++ b/screen/ActionSheet.ios.ts @@ -8,8 +8,10 @@ export default class ActionSheet { InteractionManager.runAfterInteractions(() => { const iosOptions = { ...options, - anchor: options.anchor, }; + if (options.anchor) { + iosOptions.anchor = options.anchor; + } ActionSheetIOS.showActionSheetWithOptions(iosOptions, completion); }); } From 5176eca903d68033d6aa8fa0f0981e9b3f703c37 Mon Sep 17 00:00:00 2001 From: overtorment Date: Sat, 1 Jun 2024 10:01:39 +0100 Subject: [PATCH 011/114] REF: silent-payments minor refactor --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea2144ca89..b4192f33a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -102,7 +102,7 @@ "rn-ldk": "github:BlueWallet/rn-ldk#v0.8.4", "rn-nodeify": "10.3.0", "scryptsy": "2.1.0", - "silent-payments": "github:BlueWallet/SilentPayments", + "silent-payments": "github:BlueWallet/SilentPayments#7ac4d17", "slip39": "https://github.com/BlueWallet/slip39-js", "stream-browserify": "3.0.0", "url": "0.11.3", @@ -20994,8 +20994,8 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, "node_modules/silent-payments": { - "version": "0.3.4", - "resolved": "git+ssh://git@github.com/BlueWallet/SilentPayments.git#d3a45d7f48484a1a317b444400d32956c24f0737", + "version": "1.0.0", + "resolved": "git+ssh://git@github.com/BlueWallet/SilentPayments.git#7ac4d17b85dc875a3ebb072883dd1d92ac286d98", "dependencies": { "@noble/secp256k1": "1.6.3", "bitcoinjs-lib": "^6.1.1", @@ -38331,8 +38331,8 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, "silent-payments": { - "version": "git+ssh://git@github.com/BlueWallet/SilentPayments.git#d3a45d7f48484a1a317b444400d32956c24f0737", - "from": "silent-payments@github:BlueWallet/SilentPayments", + "version": "git+ssh://git@github.com/BlueWallet/SilentPayments.git#7ac4d17b85dc875a3ebb072883dd1d92ac286d98", + "from": "silent-payments@github:BlueWallet/SilentPayments#7ac4d17", "requires": { "@noble/secp256k1": "1.6.3", "bitcoinjs-lib": "^6.1.1", diff --git a/package.json b/package.json index 9a8f6f1fa7..7f9293004e 100644 --- a/package.json +++ b/package.json @@ -187,7 +187,7 @@ "rn-ldk": "github:BlueWallet/rn-ldk#v0.8.4", "rn-nodeify": "10.3.0", "scryptsy": "2.1.0", - "silent-payments": "github:BlueWallet/SilentPayments", + "silent-payments": "github:BlueWallet/SilentPayments#7ac4d17", "slip39": "https://github.com/BlueWallet/slip39-js", "stream-browserify": "3.0.0", "url": "0.11.3", From 94d43e18557a391c8e4ada89af232495315b521b Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Sat, 1 Jun 2024 14:48:22 +0100 Subject: [PATCH 012/114] feat: entropy refactor --- class/wallets/abstract-hd-electrum-wallet.ts | 7 +- class/wallets/legacy-wallet.ts | 16 +- components/FloatButtons.tsx | 2 +- loc/en.json | 9 +- navigation/LazyLoadAddWalletStack.tsx | 2 +- screen/wallets/Add.tsx | 47 ++- .../{provideEntropy.js => ProvideEntropy.tsx} | 268 ++++++++++++------ tests/unit/hd-segwit-p2sh-wallet.test.ts | 33 +-- tests/unit/legacy-wallet.test.js | 18 +- ...ntropy.test.js => provide-entropy.test.ts} | 60 ++-- 10 files changed, 277 insertions(+), 185 deletions(-) rename screen/wallets/{provideEntropy.js => ProvideEntropy.tsx} (54%) rename tests/unit/{provide-entropy.test.js => provide-entropy.test.ts} (61%) diff --git a/class/wallets/abstract-hd-electrum-wallet.ts b/class/wallets/abstract-hd-electrum-wallet.ts index f430c7e7a0..dd5c530604 100644 --- a/class/wallets/abstract-hd-electrum-wallet.ts +++ b/class/wallets/abstract-hd-electrum-wallet.ts @@ -159,9 +159,10 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { } async generateFromEntropy(user: Buffer) { - const random = await randomBytes(user.length < 32 ? 32 - user.length : 0); - const buf = Buffer.concat([user, random], 32); - this.secret = bip39.entropyToMnemonic(buf.toString('hex')); + if (user.length !== 32 && user.length !== 16) { + throw new Error('Entropy has to be 16 or 32 bytes long'); + } + this.secret = bip39.entropyToMnemonic(user.toString('hex')); } _getExternalWIFByIndex(index: number): string | false { diff --git a/class/wallets/legacy-wallet.ts b/class/wallets/legacy-wallet.ts index 2b73ca8e47..b3b0657cea 100644 --- a/class/wallets/legacy-wallet.ts +++ b/class/wallets/legacy-wallet.ts @@ -63,18 +63,10 @@ export class LegacyWallet extends AbstractWallet { } async generateFromEntropy(user: Buffer): Promise { - let i = 0; - do { - i += 1; - const random = await randomBytes(user.length < 32 ? 32 - user.length : 0); - const buf = Buffer.concat([user, random], 32); - try { - this.secret = ECPair.fromPrivateKey(buf).toWIF(); - return; - } catch (e) { - if (i === 5) throw e; - } - } while (true); + if (user.length !== 32) { + throw new Error('Entropy should be 32 bytes'); + } + this.secret = ECPair.fromPrivateKey(user).toWIF(); } getAddress(): string | false { diff --git a/components/FloatButtons.tsx b/components/FloatButtons.tsx index a0c6059edf..f9d9b3a1aa 100644 --- a/components/FloatButtons.tsx +++ b/components/FloatButtons.tsx @@ -131,7 +131,7 @@ interface FButtonProps { last?: boolean; disabled?: boolean; onPress: () => void; - onLongPress: () => void; + onLongPress?: () => void; } export const FButton = ({ text, icon, width, first, last, ...props }: FButtonProps) => { diff --git a/loc/en.json b/loc/en.json index f10cbbc6d4..ae0e6194d0 100644 --- a/loc/en.json +++ b/loc/en.json @@ -43,7 +43,8 @@ "entropy": { "save": "Save", "title": "Entropy", - "undo": "Undo" + "undo": "Undo", + "amountOfEntropy": "{bits} of {limit} bits" }, "errors": { "broadcast": "Broadcast failed.", @@ -382,6 +383,8 @@ "add_bitcoin": "Bitcoin", "add_bitcoin_explain": "Simple and powerful Bitcoin wallet", "add_create": "Create", + "add_entropy": "Entropy", + "add_entropy_bytes": "{bytes} bytes of entropy", "add_entropy_generated": "{gen} bytes of generated entropy", "add_entropy_provide": "Provide entropy via dice rolls", "add_entropy_remain": "{gen} bytes of generated entropy. Remaining {rem} bytes will be obtained from the System random number generator.", @@ -395,6 +398,10 @@ "add_title": "Add Wallet", "add_wallet_name": "Name", "add_wallet_type": "Type", + "add_wallet_seed_length": "Seed Length", + "add_wallet_seed_length_message": "Choose the length of the seed phrase you wish to use for this wallet.", + "add_wallet_seed_length_12": "12 words", + "add_wallet_seed_length_24": "24 words", "clipboard_bitcoin": "You have a Bitcoin address on your clipboard. Would you like to use it for a transaction?", "clipboard_lightning": "You have a Lightning invoice on your clipboard. Would you like to use it for a transaction?", "details_address": "Address", diff --git a/navigation/LazyLoadAddWalletStack.tsx b/navigation/LazyLoadAddWalletStack.tsx index e7042207b4..5b0e65b392 100644 --- a/navigation/LazyLoadAddWalletStack.tsx +++ b/navigation/LazyLoadAddWalletStack.tsx @@ -11,7 +11,7 @@ const ImportWallet = lazy(() => import('../screen/wallets/import')); const PleaseBackup = lazy(() => import('../screen/wallets/PleaseBackup')); const PleaseBackupLNDHub = lazy(() => import('../screen/wallets/pleaseBackupLNDHub')); const PleaseBackupLdk = lazy(() => import('../screen/wallets/pleaseBackupLdk')); -const ProvideEntropy = lazy(() => import('../screen/wallets/provideEntropy')); +const ProvideEntropy = lazy(() => import('../screen/wallets/ProvideEntropy')); const WalletsAddMultisig = lazy(() => import('../screen/wallets/addMultisig')); const WalletsAddMultisigStep2 = lazy(() => import('../screen/wallets/addMultisigStep2')); const WalletsAddMultisigHelp = lazy(() => import('../screen/wallets/addMultisigHelp')); diff --git a/screen/wallets/Add.tsx b/screen/wallets/Add.tsx index 59090dbf85..1fe687b76b 100644 --- a/screen/wallets/Add.tsx +++ b/screen/wallets/Add.tsx @@ -3,6 +3,7 @@ import { useNavigation } from '@react-navigation/native'; import React, { useEffect, useReducer } from 'react'; import { ActivityIndicator, + Alert, Keyboard, KeyboardAvoidingView, LayoutAnimation, @@ -53,7 +54,7 @@ interface State { label: string; selectedWalletType: ButtonSelected; backdoorPressed: number; - entropy: string | any[] | undefined; + entropy: Buffer | undefined; entropyButtonText: string; } @@ -161,18 +162,13 @@ const WalletsAdd: React.FC = () => { }); }, [colorScheme, setOptions]); - const entropyGenerated = (newEntropy: string | any[]) => { + const entropyGenerated = (newEntropy: Buffer) => { let entropyTitle; if (!newEntropy) { entropyTitle = loc.wallets.add_entropy_provide; - } else if (newEntropy.length < 32) { - entropyTitle = loc.formatString(loc.wallets.add_entropy_remain, { - gen: newEntropy.length, - rem: 32 - newEntropy.length, - }); } else { - entropyTitle = loc.formatString(loc.wallets.add_entropy_generated, { - gen: newEntropy.length, + entropyTitle = loc.formatString(loc.wallets.add_entropy_bytes, { + bytes: newEntropy.length, }); } setEntropy(newEntropy); @@ -203,7 +199,7 @@ const WalletsAdd: React.FC = () => { dispatch({ type: 'INCREMENT_BACKDOOR_PRESSED', payload: value }); }; - const setEntropy = (value: string | any[]) => { + const setEntropy = (value: Buffer) => { dispatch({ type: 'SET_ENTROPY', payload: value }); }; @@ -236,7 +232,6 @@ const WalletsAdd: React.FC = () => { if (selectedWalletType === ButtonSelected.ONCHAIN) { if (entropy) { try { - // @ts-ignore: Return later to update await w.generateFromEntropy(entropy); } catch (e: any) { console.log(e.toString()); @@ -334,8 +329,34 @@ const WalletsAdd: React.FC = () => { }; const navigateToEntropy = () => { - // @ts-ignore: Return later to update - navigate('ProvideEntropy', { onGenerated: entropyGenerated }); + Alert.alert( + loc.wallets.add_wallet_seed_length, + loc.wallets.add_wallet_seed_length_message, + [ + { + text: loc._.cancel, + onPress: () => {}, + style: 'default', + }, + { + text: loc.wallets.add_wallet_seed_length_12, + onPress: () => { + // @ts-ignore: Return later to update + navigate('ProvideEntropy', { onGenerated: entropyGenerated, words: 12 }); + }, + style: 'default', + }, + { + text: loc.wallets.add_wallet_seed_length_24, + onPress: () => { + // @ts-ignore: Return later to update + navigate('ProvideEntropy', { onGenerated: entropyGenerated, words: 24 }); + }, + style: 'default', + }, + ], + { cancelable: true }, + ); }; const navigateToImportWallet = () => { diff --git a/screen/wallets/provideEntropy.js b/screen/wallets/ProvideEntropy.tsx similarity index 54% rename from screen/wallets/provideEntropy.js rename to screen/wallets/ProvideEntropy.tsx index 2bc0073f26..472d8af86f 100644 --- a/screen/wallets/provideEntropy.js +++ b/screen/wallets/ProvideEntropy.tsx @@ -1,8 +1,18 @@ import { useNavigation, useRoute } from '@react-navigation/native'; import BN from 'bignumber.js'; -import PropTypes from 'prop-types'; -import React, { useReducer, useState } from 'react'; -import { Dimensions, Image, PixelRatio, ScrollView, StyleSheet, Text, TouchableOpacity, useWindowDimensions, View } from 'react-native'; +import React, { useEffect, useReducer, useState } from 'react'; +import { + Alert, + Dimensions, + Image, + PixelRatio, + ScrollView, + StyleSheet, + Text, + TouchableOpacity, + View, + useWindowDimensions, +} from 'react-native'; import { Icon } from 'react-native-elements'; import { BlueSpacing20 } from '../../BlueComponents'; @@ -11,48 +21,81 @@ import SafeArea from '../../components/SafeArea'; import { Tabs } from '../../components/Tabs'; import { BlueCurrentTheme, useTheme } from '../../components/themes'; import loc from '../../loc'; +import { randomBytes } from '../../class/rng'; -const ENTROPY_LIMIT = 256; +export enum EActionType { + push = 'push', + pop = 'pop', + limit = 'limit', + noop = 'noop', +} -const shiftLeft = (value, places) => value.multipliedBy(2 ** places); -const shiftRight = (value, places) => value.div(2 ** places).dp(0, BN.ROUND_DOWN); +type TEntropy = { value: number; bits: number }; +type TState = { entropy: BN; bits: number; items: number[]; limit: number }; +type TAction = + | ({ type: EActionType.push } & TEntropy) + | { type: EActionType.pop } + | { type: EActionType.limit; limit: number } + | { type: EActionType.noop }; +type TPush = (v: TEntropy | null) => void; +type TPop = () => void; -const initialState = { entropy: BN(0), bits: 0, items: [] }; -export const eReducer = (state = initialState, action) => { +const initialState: TState = { + entropy: BN(0), + bits: 0, + items: [], + limit: 256, +}; + +const shiftLeft = (value: BN, places: number) => value.multipliedBy(2 ** places); +const shiftRight = (value: BN, places: number) => value.div(2 ** places).dp(0, BN.ROUND_DOWN); + +export const eReducer = (state: TState = initialState, action: TAction): TState => { switch (action.type) { - case 'push': { - let { value, bits } = action; + case EActionType.noop: + return state; + + case EActionType.push: { + let value: number | BN = action.value; + let bits: number = action.bits; + if (value >= 2 ** bits) { throw new TypeError("Can't push value exceeding size in bits"); } - if (state.bits === ENTROPY_LIMIT) return state; - if (state.bits + bits > ENTROPY_LIMIT) { - value = shiftRight(BN(value), bits + state.bits - ENTROPY_LIMIT); - bits = ENTROPY_LIMIT - state.bits; + if (state.bits === state.limit) return state; + if (state.bits + bits > state.limit) { + value = shiftRight(BN(value), bits + state.bits - state.limit); + bits = state.limit - state.bits; } const entropy = shiftLeft(state.entropy, bits).plus(value); const items = [...state.items, bits]; - return { entropy, bits: state.bits + bits, items }; + return { ...state, entropy, bits: state.bits + bits, items }; } - case 'pop': { + + case EActionType.pop: { if (state.bits === 0) return state; - const bits = state.items.pop(); + const bits = state.items.pop()!; const entropy = shiftRight(state.entropy, bits); - return { entropy, bits: state.bits - bits, items: [...state.items] }; + return { ...state, entropy, bits: state.bits - bits, items: [...state.items] }; + } + + case EActionType.limit: { + return { ...state, limit: action.limit }; } + default: return state; } }; -export const entropyToHex = ({ entropy, bits }) => { +export const entropyToHex = ({ entropy, bits }: { entropy: BN; bits: number }): string => { if (bits === 0) return '0x'; const hex = entropy.toString(16); const hexSize = Math.floor((bits - 1) / 4) + 1; return '0x' + '0'.repeat(hexSize - hex.length) + hex; }; -export const getEntropy = (number, base) => { +export const getEntropy = (number: number, base: number): TEntropy | null => { if (base === 1) return null; let maxPow = 1; while (2 ** (maxPow + 1) <= base) { @@ -77,12 +120,12 @@ export const getEntropy = (number, base) => { }; // cut entropy to bytes, convert to Buffer -export const convertToBuffer = ({ entropy, bits }) => { +export const convertToBuffer = ({ entropy, bits }: { entropy: BN; bits: number }): Buffer => { if (bits < 8) return Buffer.from([]); const bytes = Math.floor(bits / 8); // convert to byte array - let arr = []; + const arr: string[] = []; const ent = entropy.toString(16).split('').reverse(); ent.forEach((v, index) => { if (index % 2 === 1) { @@ -91,18 +134,19 @@ export const convertToBuffer = ({ entropy, bits }) => { arr.unshift(v); } }); - arr = arr.map(i => parseInt(i, 16)); + + let arr2 = arr.map(i => parseInt(i, 16)); if (arr.length > bytes) { - arr.shift(); - } else if (arr.length < bytes) { - const zeros = [...Array(bytes - arr.length)].map(() => 0); - arr = [...zeros, ...arr]; + arr2.shift(); + } else if (arr2.length < bytes) { + const zeros = [...Array(bytes - arr2.length)].map(() => 0); + arr2 = [...zeros, ...arr2]; } - return Buffer.from(arr); + return Buffer.from(arr2); }; -const Coin = ({ push }) => ( +const Coin = ({ push }: { push: TPush }) => ( push(getEntropy(0, 2))} style={styles.coinBody}> @@ -113,11 +157,24 @@ const Coin = ({ push }) => ( ); -Coin.propTypes = { - push: PropTypes.func.isRequired, +const diceIcon = (i: number): string => { + switch (i) { + case 1: + return 'dice-one'; + case 2: + return 'dice-two'; + case 3: + return 'dice-three'; + case 4: + return 'dice-four'; + case 5: + return 'dice-five'; + default: + return 'dice-six'; + } }; -const Dice = ({ push, sides }) => { +const Dice = ({ push, sides }: { push: TPush; sides: number }) => { const { width } = useWindowDimensions(); const { colors } = useTheme(); const diceWidth = width / 4; @@ -132,22 +189,6 @@ const Dice = ({ push, sides }) => { backgroundColor: colors.elevated, }, }); - const diceIcon = i => { - switch (i) { - case 1: - return 'dice-one'; - case 2: - return 'dice-two'; - case 3: - return 'dice-three'; - case 4: - return 'dice-four'; - case 5: - return 'dice-five'; - default: - return 'dice-six'; - } - }; return ( @@ -168,48 +209,53 @@ const Dice = ({ push, sides }) => { ); }; -Dice.propTypes = { - sides: PropTypes.number.isRequired, - push: PropTypes.func.isRequired, -}; - const buttonFontSize = PixelRatio.roundToNearestPixel(Dimensions.get('window').width / 26) > 22 ? 22 : PixelRatio.roundToNearestPixel(Dimensions.get('window').width / 26); -const Buttons = ({ pop, save, colors }) => ( +const Buttons = ({ pop, save, colors }: { pop: TPop; save: () => void; colors: any }) => ( } - text={loc.entropy.undo} /> } - text={loc.entropy.save} /> ); -Buttons.propTypes = { - pop: PropTypes.func.isRequired, - save: PropTypes.func.isRequired, - colors: PropTypes.shape.isRequired, +const TollTab = ({ active }: { active: boolean }) => { + const { colors } = useTheme(); + return ; +}; + +const D6Tab = ({ active }: { active: boolean }) => { + const { colors } = useTheme(); + return ; +}; + +const D20Tab = ({ active }: { active: boolean }) => { + const { colors } = useTheme(); + return ; }; const Entropy = () => { const [entropy, dispatch] = useReducer(eReducer, initialState); - const { onGenerated } = useRoute().params; + // @ts-ignore: navigation is not typed yet + const { onGenerated, words } = useRoute().params; const navigation = useNavigation(); const [tab, setTab] = useState(1); const [show, setShow] = useState(false); @@ -223,12 +269,65 @@ const Entropy = () => { }, }); - const push = v => v && dispatch({ type: 'push', value: v.value, bits: v.bits }); - const pop = () => dispatch({ type: 'pop' }); - const save = () => { - navigation.pop(); - const buf = convertToBuffer(entropy); - onGenerated(buf); + useEffect(() => { + dispatch({ type: EActionType.limit, limit: words === 24 ? 256 : 128 }); + }, [dispatch, words]); + + const handlePush: TPush = v => { + if (v === null) { + dispatch({ type: EActionType.noop }); + } else { + dispatch({ type: EActionType.push, value: v.value, bits: v.bits }); + } + }; + + const handlePop: TPop = () => { + dispatch({ type: EActionType.pop }); + }; + + const handleSave = async () => { + let buf = convertToBuffer(entropy); + const bufLength = words === 24 ? 32 : 16; + const remaining = bufLength - buf.length; + + let entropyTitle = ''; + if (buf.length < bufLength) { + entropyTitle = loc.formatString(loc.wallets.add_entropy_remain, { + gen: buf.length, + rem: remaining, + }); + } else { + entropyTitle = loc.formatString(loc.wallets.add_entropy_generated, { + gen: buf.length, + }); + } + + Alert.alert( + loc.wallets.add_entropy, + entropyTitle, + [ + { + text: loc._.ok, + onPress: async () => { + if (remaining > 0) { + const random = await randomBytes(remaining); + buf = Buffer.concat([buf, random], bufLength); + } + + // @ts-ignore: navigation is not typed yet + navigation.pop(); + onGenerated(buf); + }, + style: 'default', + }, + { + text: loc._.cancel, + onPress: () => {}, + style: 'default', + }, + ], + { cancelable: true }, + ); }; const hex = entropyToHex(entropy); @@ -240,34 +339,19 @@ const Entropy = () => { setShow(!show)}> - {show ? hex : `${bits} of 256 bits`} + + {show ? hex : loc.formatString(loc.entropy.amountOfEntropy, { bits, limit: entropy.limit })} + - ( - - ), - // eslint-disable-next-line react/no-unstable-nested-components - ({ active }) => ( - - ), - // eslint-disable-next-line react/no-unstable-nested-components - ({ active }) => ( - - ), - ]} - /> - - {tab === 0 && } - {tab === 1 && } - {tab === 2 && } - - + + + {tab === 0 && } + {tab === 1 && } + {tab === 2 && } + + ); }; diff --git a/tests/unit/hd-segwit-p2sh-wallet.test.ts b/tests/unit/hd-segwit-p2sh-wallet.test.ts index 9bd652036e..84d1b22265 100644 --- a/tests/unit/hd-segwit-p2sh-wallet.test.ts +++ b/tests/unit/hd-segwit-p2sh-wallet.test.ts @@ -140,31 +140,26 @@ describe('P2SH Segwit HD (BIP49)', () => { }); it('can consume user generated entropy', async () => { - const hd = new HDSegwitP2SHWallet(); - const zeroes = [...Array(32)].map(() => 0); - await hd.generateFromEntropy(Buffer.from(zeroes)); + const hd1 = new HDSegwitP2SHWallet(); + const zeroes16 = [...Array(16)].map(() => 0); + await hd1.generateFromEntropy(Buffer.from(zeroes16)); + assert.strictEqual(hd1.getSecret(), 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'); + + const hd2 = new HDSegwitP2SHWallet(); + const zeroes32 = [...Array(32)].map(() => 0); + await hd2.generateFromEntropy(Buffer.from(zeroes32)); assert.strictEqual( - hd.getSecret(), + hd2.getSecret(), 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art', ); }); - it('can fullfill user generated entropy if less than 32 bytes provided', async () => { + it('throws an error if not 32 bytes provided', async () => { const hd = new HDSegwitP2SHWallet(); - const zeroes = [...Array(16)].map(() => 0); - await hd.generateFromEntropy(Buffer.from(zeroes)); - const secret = hd.getSecret(); - assert.strictEqual(secret.startsWith('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon'), true); - - const secretWithoutChecksum = secret.split(' '); - secretWithoutChecksum.pop(); - const secretWithoutChecksumString = secretWithoutChecksum.join(' '); - assert.strictEqual( - secretWithoutChecksumString.endsWith('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon'), - false, - ); - - assert.ok(secret.split(' ').length === 12 || secret.split(' ').length === 24); + const values = [...Array(31)].map(() => 1); + await assert.rejects(async () => await hd.generateFromEntropy(Buffer.from(values)), { + message: 'Entropy has to be 16 or 32 bytes long', + }); }); it('can sign and verify messages', async () => { diff --git a/tests/unit/legacy-wallet.test.js b/tests/unit/legacy-wallet.test.js index 574a26b461..a5ff4fe703 100644 --- a/tests/unit/legacy-wallet.test.js +++ b/tests/unit/legacy-wallet.test.js @@ -1,10 +1,7 @@ import assert from 'assert'; import * as bitcoin from 'bitcoinjs-lib'; -import { ECPairFactory } from 'ecpair'; -import ecc from '../../blue_modules/noble_ecc'; import { LegacyWallet } from '../../class'; -const ECPair = ECPairFactory(ecc); describe('Legacy wallet', () => { it('can validate addresses', () => { @@ -146,17 +143,12 @@ describe('Legacy wallet', () => { assert.strictEqual(l.getSecret(), 'KwFfNUhSDaASSAwtG7ssQM1uVX8RgX5GHWnnLfhfiQDigjioWXHH'); }); - it('can fullfill user generated entropy if less than 32 bytes provided', async () => { + it('throws an error if not 32 bytes provided', async () => { const l = new LegacyWallet(); - const values = [...Array(16)].map(() => 1); - await l.generateFromEntropy(Buffer.from(values)); - assert.strictEqual(l.getSecret().startsWith('KwFfNUhSDaASSAwtG7ssQM'), true); - assert.strictEqual(l.getSecret().endsWith('GHWnnLfhfiQDigjioWXHH'), false); - const keyPair = ECPair.fromWIF(l.getSecret()); - assert.strictEqual(keyPair.privateKey.toString('hex').startsWith('01010101'), true); - assert.strictEqual(keyPair.privateKey.toString('hex').endsWith('01010101'), false); - assert.strictEqual(keyPair.privateKey.toString('hex').endsWith('00000000'), false); - assert.strictEqual(keyPair.privateKey.toString('hex').endsWith('ffffffff'), false); + const values = [...Array(31)].map(() => 1); + await assert.rejects(async () => await l.generateFromEntropy(Buffer.from(values)), { + message: 'Entropy should be 32 bytes', + }); }); it('can sign and verify messages', async () => { diff --git a/tests/unit/provide-entropy.test.js b/tests/unit/provide-entropy.test.ts similarity index 61% rename from tests/unit/provide-entropy.test.js rename to tests/unit/provide-entropy.test.ts index 81888eda38..8e108938f2 100644 --- a/tests/unit/provide-entropy.test.js +++ b/tests/unit/provide-entropy.test.ts @@ -1,69 +1,69 @@ import assert from 'assert'; -import { convertToBuffer, entropyToHex, eReducer, getEntropy } from '../../screen/wallets/provideEntropy'; +import { convertToBuffer, EActionType, entropyToHex, eReducer, getEntropy } from '../../screen/wallets/ProvideEntropy'; describe('Entropy reducer and format', () => { it('handles push and pop correctly', () => { - let state = eReducer(undefined, { type: null }); + let state = eReducer(undefined, { type: EActionType.noop }); assert.equal(entropyToHex(state), '0x'); - state = eReducer(state, { type: 'push', value: 0, bits: 1 }); + state = eReducer(state, { type: EActionType.push, value: 0, bits: 1 }); assert.equal(entropyToHex(state), '0x0'); - state = eReducer(state, { type: 'push', value: 0, bits: 1 }); + state = eReducer(state, { type: EActionType.push, value: 0, bits: 1 }); assert.equal(entropyToHex(state), '0x0'); - state = eReducer(state, { type: 'push', value: 0, bits: 3 }); + state = eReducer(state, { type: EActionType.push, value: 0, bits: 3 }); assert.equal(entropyToHex(state), '0x00'); - state = eReducer(state, { type: 'pop' }); + state = eReducer(state, { type: EActionType.pop }); assert.equal(entropyToHex(state), '0x0'); - state = eReducer(state, { type: 'pop' }); - state = eReducer(state, { type: 'pop' }); + state = eReducer(state, { type: EActionType.pop }); + state = eReducer(state, { type: EActionType.pop }); assert.equal(entropyToHex(state), '0x'); - state = eReducer(state, { type: 'push', value: 1, bits: 1 }); + state = eReducer(state, { type: EActionType.push, value: 1, bits: 1 }); assert.equal(entropyToHex(state), '0x1'); // 0b1 - state = eReducer(state, { type: 'push', value: 0, bits: 1 }); + state = eReducer(state, { type: EActionType.push, value: 0, bits: 1 }); assert.equal(entropyToHex(state), '0x2'); // 0b10 - state = eReducer(state, { type: 'push', value: 0b01, bits: 2 }); + state = eReducer(state, { type: EActionType.push, value: 0b01, bits: 2 }); assert.equal(entropyToHex(state), '0x9'); // 0b1001 - state = eReducer(state, { type: 'push', value: 0b10, bits: 2 }); + state = eReducer(state, { type: EActionType.push, value: 0b10, bits: 2 }); assert.equal(entropyToHex(state), '0x26'); // 0b100110 }); it('handles 128 bits correctly', () => { - const state = eReducer(undefined, { type: 'push', value: 0, bits: 128 }); + const state = eReducer(undefined, { type: EActionType.push, value: 0, bits: 128 }); assert.equal(entropyToHex(state), '0x00000000000000000000000000000000'); }); it('handles 256 bits correctly', () => { - let state = eReducer(undefined, { type: null }); // get init state + let state = eReducer(undefined, { type: EActionType.noop }); // get init state // eslint-disable-next-line @typescript-eslint/no-unused-vars for (const i of [...Array(256)]) { - state = eReducer(state, { type: 'push', value: 1, bits: 1 }); + state = eReducer(state, { type: EActionType.push, value: 1, bits: 1 }); } assert.equal(entropyToHex(state), '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); }); it('handles pop when empty without error', () => { - const state = eReducer(undefined, { type: 'pop' }); + const state = eReducer(undefined, { type: EActionType.pop }); assert.equal(entropyToHex(state), '0x'); }); it('handles 256 bits limit', () => { - let state = eReducer(undefined, { type: 'push', value: 0, bits: 254 }); - state = eReducer(state, { type: 'push', value: 0b101, bits: 3 }); + let state = eReducer(undefined, { type: EActionType.push, value: 0, bits: 254 }); + state = eReducer(state, { type: EActionType.push, value: 0b101, bits: 3 }); assert.equal(entropyToHex(state), '0x0000000000000000000000000000000000000000000000000000000000000002'); }); it('Throws error if you try to push value exceeding size in bits', () => { - assert.throws(() => eReducer(undefined, { type: 'push', value: 8, bits: 3 }), { + assert.throws(() => eReducer(undefined, { type: EActionType.push, value: 8, bits: 3 }), { name: 'TypeError', message: "Can't push value exceeding size in bits", }); @@ -104,48 +104,48 @@ describe('getEntropy function', () => { describe('convertToBuffer function', () => { it('zero bits', () => { - const state = eReducer(undefined, { type: null }); + const state = eReducer(undefined, { type: EActionType.noop }); assert.deepEqual(convertToBuffer(state), Buffer.from([])); }); it('8 zero bits', () => { - const state = eReducer(undefined, { type: 'push', value: 0, bits: 8 }); + const state = eReducer(undefined, { type: EActionType.push, value: 0, bits: 8 }); assert.deepEqual(convertToBuffer(state), Buffer.from([0])); }); it('8 filled bits', () => { - const state = eReducer(undefined, { type: 'push', value: 0b11111111, bits: 8 }); + const state = eReducer(undefined, { type: EActionType.push, value: 0b11111111, bits: 8 }); assert.deepEqual(convertToBuffer(state), Buffer.from([0b11111111])); }); it('9 zero bits', () => { - const state = eReducer(undefined, { type: 'push', value: 0, bits: 9 }); + const state = eReducer(undefined, { type: EActionType.push, value: 0, bits: 9 }); assert.deepEqual(convertToBuffer(state), Buffer.from([0])); }); it('9 filled bits', () => { - const state = eReducer(undefined, { type: 'push', value: 0b111111111, bits: 9 }); + const state = eReducer(undefined, { type: EActionType.push, value: 0b111111111, bits: 9 }); assert.deepEqual(convertToBuffer(state), Buffer.from([0b11111111])); }); it('9 bits', () => { - const state = eReducer(undefined, { type: 'push', value: 0b111100111, bits: 9 }); + const state = eReducer(undefined, { type: EActionType.push, value: 0b111100111, bits: 9 }); assert.deepEqual(convertToBuffer(state), Buffer.from([0b11100111])); }); it('3 bytes', () => { - let state = eReducer(undefined, { type: 'push', value: 1, bits: 8 }); - state = eReducer(state, { type: 'push', value: 2, bits: 8 }); - state = eReducer(state, { type: 'push', value: 3, bits: 8 }); + let state = eReducer(undefined, { type: EActionType.push, value: 1, bits: 8 }); + state = eReducer(state, { type: EActionType.push, value: 2, bits: 8 }); + state = eReducer(state, { type: EActionType.push, value: 3, bits: 8 }); assert.deepEqual(convertToBuffer(state), Buffer.from([1, 2, 3])); }); it('256 bits or 32bytes', () => { - let state = eReducer(undefined, { type: null }); // get init state + let state = eReducer(undefined, { type: EActionType.noop }); // get init state // eslint-disable-next-line @typescript-eslint/no-unused-vars for (const i of [...Array(256)]) { - state = eReducer(state, { type: 'push', value: 1, bits: 1 }); + state = eReducer(state, { type: EActionType.push, value: 1, bits: 1 }); } const bytes = [...Array(32)].map(() => 255); From d399b51afbc34c8c1cb937b534821cbaf7c107b2 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 1 Jun 2024 15:48:14 -0400 Subject: [PATCH 013/114] REF: Update icons --- screen/wallets/PaymentCodesList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index e79cefe00c..59d8a96652 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -41,7 +41,7 @@ const actionKeys: Action[] = [ text: loc.bip47.pay_this_contact, icon: { iconType: 'SYSTEM', - iconValue: 'square.and.arrow.up', + iconValue: 'paperplane', }, }, { @@ -57,7 +57,7 @@ const actionKeys: Action[] = [ text: loc.bip47.copy_payment_code, icon: { iconType: 'SYSTEM', - iconValue: 'doc.on.doc', + iconValue: 'pencil', }, }, ]; From 46555ca46fa41ddeb0044e36519819056d9e3fec Mon Sep 17 00:00:00 2001 From: stellrust Date: Sun, 2 Jun 2024 04:21:27 +0800 Subject: [PATCH 014/114] chore: fix some comments (#6638) --- blue_modules/notifications.js | 2 +- helpers/select-wallet.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blue_modules/notifications.js b/blue_modules/notifications.js index 8a77a3d022..c8c5118c4d 100644 --- a/blue_modules/notifications.js +++ b/blue_modules/notifications.js @@ -259,7 +259,7 @@ function Notifications(props) { }; Notifications.saveUri = async function (uri) { - baseURI = uri || groundControlUri; // settign the url to use currently. if not set - use default + baseURI = uri || groundControlUri; // setting the url to use currently. if not set - use default return AsyncStorage.setItem(GROUNDCONTROL_BASE_URI, uri); }; diff --git a/helpers/select-wallet.ts b/helpers/select-wallet.ts index 8bdb53e825..b8ae24b5dc 100644 --- a/helpers/select-wallet.ts +++ b/helpers/select-wallet.ts @@ -4,7 +4,7 @@ * * @param navigateFunc {function} Function that does navigatino should be passed from outside * @param currentScreenName {string} Current screen name, so we know to what screen to get back to - * @param chainType {string} One of `Chain.` constant to be used to filter wallet pannels to show + * @param chainType {string} One of `Chain.` constant to be used to filter wallet panels to show * @param availableWallets {array} Wallets to be present in selector. If set, overrides `chainType` * @param noWalletExplanationText {string} Text that is displayed when there are no wallets to select from * From 89561c07627fd557b41613df04d23f3cc21ef533 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 1 Jun 2024 18:33:17 -0400 Subject: [PATCH 015/114] FIX: Add contact dialog could not be canceled --- screen/wallets/PaymentCodesList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index 59d8a96652..7ce87320bb 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -168,7 +168,7 @@ export default function PaymentCodesList() { const foundWallet = wallets.find(w => w.getID() === walletID) as unknown as HDSegwitBech32Wallet; assert(foundWallet); - const newPc = await prompt(loc.bip47.add_contact, loc.bip47.provide_payment_code, false, 'plain-text'); + const newPc = await prompt(loc.bip47.add_contact, loc.bip47.provide_payment_code, true, 'plain-text'); if (!newPc) return; const cl = new ContactList(); From 24adc7f57eb635c25fb4ee40b065bcd7573ab04e Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 1 Jun 2024 22:57:19 -0400 Subject: [PATCH 016/114] FIX: Wrong button during initial mount --- navigation/DetailViewScreensStack.tsx | 12 ++++++++++-- screen/transactions/TransactionDetails.tsx | 13 +------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/navigation/DetailViewScreensStack.tsx b/navigation/DetailViewScreensStack.tsx index a55a78bce4..7211b0ecce 100644 --- a/navigation/DetailViewScreensStack.tsx +++ b/navigation/DetailViewScreensStack.tsx @@ -83,6 +83,7 @@ const DetailViewStackScreensStack = () => { }; const SaveButton = useMemo(() => , []); + const DetailButton = useMemo(() => , []); const useWalletListScreenOptions = useMemo(() => { const SettingsButton = ( @@ -148,7 +149,14 @@ const DetailViewStackScreensStack = () => { DetailButton, + })(theme)} /> { headerStyle: { backgroundColor: theme.colors.customHeader, }, - headerRight: () => SaveButton, + headerRight: () => DetailButton, })(theme)} /> diff --git a/screen/transactions/TransactionDetails.tsx b/screen/transactions/TransactionDetails.tsx index 530e5b3f5b..da83f77604 100644 --- a/screen/transactions/TransactionDetails.tsx +++ b/screen/transactions/TransactionDetails.tsx @@ -12,7 +12,6 @@ import presentAlert from '../../components/Alert'; import CopyToClipboardButton from '../../components/CopyToClipboardButton'; import HandOffComponent from '../../components/HandOffComponent'; import HeaderRightButton from '../../components/HeaderRightButton'; -import navigationStyle from '../../components/navigationStyle'; import { useTheme } from '../../components/themes'; import ToolTipMenu from '../../components/TooltipMenu'; import loc from '../../loc'; @@ -414,14 +413,4 @@ const styles = StyleSheet.create({ }, }); -export default TransactionDetails; - -TransactionDetails.navigationOptions = navigationStyle({ headerTitle: loc.transactions.details_title }, (options, { theme }) => { - return { - ...options, - statusBarStyle: 'auto', - headerStyle: { - backgroundColor: theme.colors.customHeader, - }, - }; -}); +export default TransactionDetails; \ No newline at end of file From c70368190b16d3960997f59879ce070ed388610c Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 1 Jun 2024 23:50:34 -0400 Subject: [PATCH 017/114] Update TransactionDetails.tsx --- screen/transactions/TransactionDetails.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/screen/transactions/TransactionDetails.tsx b/screen/transactions/TransactionDetails.tsx index da83f77604..9026b9ea86 100644 --- a/screen/transactions/TransactionDetails.tsx +++ b/screen/transactions/TransactionDetails.tsx @@ -105,7 +105,14 @@ const TransactionDetails = () => { }, [tx, txMetadata, memo, counterpartyLabel, paymentCode, saveToDisk, counterpartyMetadata]); const HeaderRight = useMemo( - () => , + () => ( + + ), [handleOnSaveButtonTapped], ); @@ -413,4 +420,4 @@ const styles = StyleSheet.create({ }, }); -export default TransactionDetails; \ No newline at end of file +export default TransactionDetails; From 8dec7ccbacbddeae5a556c40753fe04a17132116 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sun, 2 Jun 2024 11:38:30 -0400 Subject: [PATCH 018/114] FIX: Contact name was not visible with dark mode --- screen/wallets/PaymentCodesList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index 7ce87320bb..36f2d5d3db 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -145,7 +145,7 @@ export default function PaymentCodesList() { - {displayName} + {displayName} From 0819d3b2ccdf84a4e3706eb057570f23d8ea71f4 Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Sun, 2 Jun 2024 19:31:28 +0100 Subject: [PATCH 019/114] fix: TS localization vocabulary --- components/TransactionListItem.tsx | 6 +++--- loc/index.ts | 26 +++++++++++++++++--------- navigation/SendDetailsStack.tsx | 2 +- screen/settings/EncryptStorage.tsx | 6 +++--- screen/wallets/WalletsList.tsx | 2 +- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/components/TransactionListItem.tsx b/components/TransactionListItem.tsx index 3981541541..9de19db3a7 100644 --- a/components/TransactionListItem.tsx +++ b/components/TransactionListItem.tsx @@ -73,7 +73,7 @@ export const TransactionListItem: React.FC = React.mem if (sub !== '') sub += ' '; sub += txMemo; if (item.memo) sub += item.memo; - return sub || null; + return sub || undefined; }, [txMemo, item.confirmations, item.memo]); const rowTitle = useMemo(() => { @@ -87,7 +87,7 @@ export const TransactionListItem: React.FC = React.mem if (invoiceExpiration > now) { return formatBalanceWithoutSuffix(item.value && item.value, itemPriceUnit, true).toString(); - } else if (invoiceExpiration < now) { + } else { if (item.ispaid) { return formatBalanceWithoutSuffix(item.value && item.value, itemPriceUnit, true).toString(); } else { @@ -249,7 +249,7 @@ export const TransactionListItem: React.FC = React.mem const handleOnCopyAmountTap = useCallback(() => Clipboard.setString(rowTitle.replace(/[\s\\-]/g, '')), [rowTitle]); const handleOnCopyTransactionID = useCallback(() => Clipboard.setString(item.hash), [item.hash]); - const handleOnCopyNote = useCallback(() => Clipboard.setString(subtitle), [subtitle]); + const handleOnCopyNote = useCallback(() => Clipboard.setString(subtitle ?? ''), [subtitle]); const handleOnViewOnBlockExplorer = useCallback(() => { const url = `https://mempool.space/tx/${item.hash}`; Linking.canOpenURL(url).then(supported => { diff --git a/loc/index.ts b/loc/index.ts index 6633d5cba8..82fbaa5eb2 100644 --- a/loc/index.ts +++ b/loc/index.ts @@ -3,19 +3,27 @@ import BigNumber from 'bignumber.js'; import dayjs from 'dayjs'; import localizedFormat from 'dayjs/plugin/localizedFormat'; import relativeTime from 'dayjs/plugin/relativeTime'; -import Localization from 'react-localization'; +import Localization, { LocalizedStrings } from 'react-localization'; import { I18nManager } from 'react-native'; import * as RNLocalize from 'react-native-localize'; import { satoshiToLocalCurrency } from '../blue_modules/currency'; import { BitcoinUnit } from '../models/bitcoinUnits'; import { AvailableLanguages } from './languages'; +import enJson from './en.json'; export const STORAGE_KEY = 'lang'; dayjs.extend(relativeTime); dayjs.extend(localizedFormat); +interface ILocalization1 extends LocalizedStrings {} + +// overriding formatString to only return string +interface ILocalization extends Omit { + formatString: (...args: Parameters) => string; +} + const setDateTimeLocale = async () => { let lang = (await AsyncStorage.getItem(STORAGE_KEY)) ?? ''; let localeForDayJSAvailable = true; @@ -206,8 +214,8 @@ const init = async () => { }; init(); -const loc = new Localization({ - en: require('./en.json'), +const loc: ILocalization = new Localization({ + en: enJson, ar: require('./ar.json'), be: require('./be@tarask.json'), bg_bg: require('./bg_bg.json'), @@ -281,12 +289,12 @@ export const transactionTimeToReadable = (time: number) => { ret = dayjs(time).fromNow(); } catch (_) { console.warn('incorrect locale set for dayjs'); - return time; + return String(time); } return ret; }; -export const removeTrailingZeros = (value: number | string) => { +export const removeTrailingZeros = (value: number | string): string => { let ret = value.toString(); if (ret.indexOf('.') === -1) { @@ -305,7 +313,7 @@ export const removeTrailingZeros = (value: number | string) => { * @param withFormatting {boolean} Works only with `BitcoinUnit.SATS`, makes spaces wetween groups of 000 * @returns {string} */ -export function formatBalance(balance: number, toUnit: string, withFormatting = false) { +export function formatBalance(balance: number, toUnit: string, withFormatting = false): string { if (toUnit === undefined) { return balance + ' ' + loc.units[BitcoinUnit.BTC]; } @@ -314,7 +322,7 @@ export function formatBalance(balance: number, toUnit: string, withFormatting = return removeTrailingZeros(+value) + ' ' + loc.units[BitcoinUnit.BTC]; } else if (toUnit === BitcoinUnit.SATS) { return (withFormatting ? new Intl.NumberFormat().format(balance).toString() : String(balance)) + ' ' + loc.units[BitcoinUnit.SATS]; - } else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) { + } else { return satoshiToLocalCurrency(balance); } } @@ -326,7 +334,7 @@ export function formatBalance(balance: number, toUnit: string, withFormatting = * @param withFormatting {boolean} Works only with `BitcoinUnit.SATS`, makes spaces wetween groups of 000 * @returns {string} */ -export function formatBalanceWithoutSuffix(balance = 0, toUnit: string, withFormatting = false) { +export function formatBalanceWithoutSuffix(balance = 0, toUnit: string, withFormatting = false): string | number { if (toUnit === undefined) { return balance; } @@ -336,7 +344,7 @@ export function formatBalanceWithoutSuffix(balance = 0, toUnit: string, withForm return removeTrailingZeros(value); } else if (toUnit === BitcoinUnit.SATS) { return withFormatting ? new Intl.NumberFormat().format(balance).toString() : String(balance); - } else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) { + } else { return satoshiToLocalCurrency(balance); } } diff --git a/navigation/SendDetailsStack.tsx b/navigation/SendDetailsStack.tsx index b88361a344..bc00ba1240 100644 --- a/navigation/SendDetailsStack.tsx +++ b/navigation/SendDetailsStack.tsx @@ -22,7 +22,7 @@ const Stack = createNativeStackNavigator(); const SendDetailsStack = () => { const theme = useTheme(); - const DetailsButton = useMemo(() => , []); + const DetailsButton = useMemo(() => , []); return ( diff --git a/screen/settings/EncryptStorage.tsx b/screen/settings/EncryptStorage.tsx index 8b041ee22f..a36a467400 100644 --- a/screen/settings/EncryptStorage.tsx +++ b/screen/settings/EncryptStorage.tsx @@ -195,7 +195,7 @@ const EncryptStorage = () => { return isCapable ? ( <> - {loc.formatString(loc.settings.biometrics_fail, { type: deviceBiometricType })} + {loc.formatString(loc.settings.biometrics_fail, { type: deviceBiometricType! })} ) : null; }; @@ -213,14 +213,14 @@ const EncryptStorage = () => { {loc.settings.biometrics} - {loc.formatString(loc.settings.encrypt_use_expl, { type: deviceBiometricType })} + {loc.formatString(loc.settings.encrypt_use_expl, { type: deviceBiometricType! })} {renderPasscodeExplanation()} diff --git a/screen/wallets/WalletsList.tsx b/screen/wallets/WalletsList.tsx index 55707529b0..f96ceba7d9 100644 --- a/screen/wallets/WalletsList.tsx +++ b/screen/wallets/WalletsList.tsx @@ -367,7 +367,7 @@ const WalletsList: React.FC = () => { const anchor = findNodeHandle(walletActionButtonsRef.current); if (anchor) { - options.push(anchor); + options.push(String(anchor)); } ActionSheet.showActionSheetWithOptions(props, buttonIndex => { From 06cd089c75a3fecc7bc68373113ae9f9e9794329 Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Sun, 2 Jun 2024 19:38:46 +0100 Subject: [PATCH 020/114] fix: sync language files --- loc/ar.json | 7 ++----- loc/bqi.json | 8 ++++++++ loc/ca.json | 4 ++-- loc/cs_cz.json | 30 ++++++++++++++++++++++++------ loc/cy.json | 2 ++ loc/de_de.json | 2 +- loc/el.json | 4 +--- loc/es.json | 5 ++--- loc/es_419.json | 3 ++- loc/fa.json | 21 +++++++++++++++------ loc/fi_fi.json | 45 ++++++++++++++++++++++++++++++++++++--------- loc/fr_fr.json | 5 ++--- loc/he.json | 6 ++---- loc/hu_hu.json | 5 ++--- loc/id_id.json | 2 +- loc/it.json | 6 +----- loc/jp_jp.json | 26 ++++++++++++++++++++++---- loc/kk@Cyrl.json | 1 - loc/ko_KR.json | 5 ++--- loc/ms.json | 5 ++--- loc/nb_no.json | 5 ++--- loc/ne.json | 3 +-- loc/nl_nl.json | 5 ++--- loc/pl.json | 6 ++---- loc/pt_br.json | 9 ++++----- loc/pt_pt.json | 4 ++-- loc/ro.json | 5 ++--- loc/ru.json | 7 ++----- loc/si_LK.json | 5 ++--- loc/sk_sk.json | 2 +- loc/sl_SI.json | 5 ++--- loc/sv_se.json | 7 ++----- loc/th_th.json | 3 ++- loc/tr_tr.json | 1 + loc/ua.json | 2 ++ loc/vi_vn.json | 6 +----- loc/zh_cn.json | 5 ++--- loc/zh_tw.json | 5 ++--- 38 files changed, 163 insertions(+), 114 deletions(-) diff --git a/loc/ar.json b/loc/ar.json index 821a5a699b..82bd178559 100644 --- a/loc/ar.json +++ b/loc/ar.json @@ -318,7 +318,6 @@ "cpfp_title": "تسريع المعاملة (CPFP)", "details_balance_hide": "إخفاء الرصيد", "details_balance_show": "عرض الرصيد", - "details_block": "ارتفاع الكتلة", "details_copy": "نسخ", "details_copy_amount": "نسخ المبلغ", "details_copy_block_explorer_link": "نسخ رابط متصفح الكتل", @@ -329,7 +328,7 @@ "details_outputs": "المخرجات", "date": "التاريخ", "details_received": "التاريخ", - "transaction_note_saved": "تم حفظ مذكرة المعاملة بنجاح.", + "transaction_saved": "تم الحفظ", "details_show_in_block_explorer": "العرض في مستكشف الكتل", "details_title": "العملية", "details_to": "إلى", @@ -418,9 +417,9 @@ "list_empty_txs2": "ابدأ بمحفظتك", "list_empty_txs2_lightning": "\nللبدء في استخدامها، اضغط على \"إدارة الأموال\" واشحن رصيدك.", "list_latest_transaction": "آخر عملية", - "list_ln_browser": "متصفح LApp", "list_long_choose": "اختيار صورة", "list_long_clipboard": "النسخ من الحافظة", + "import_file": "استيراد ملف", "list_long_scan": "مسح رمز الاستجابة (QR) ضوئيًا", "list_title": "المحافظ", "list_tryagain": "إعادة المحاولة", @@ -561,8 +560,6 @@ }, "bip47": { "payment_code": "كود الدفع", - "payment_codes_list": "قائمة أكواد الدفع", - "who_can_pay_me": "من يستطيع الدفع لي:", "purpose": "أكواد المشاركة التي يمكن أعادة استخدامها (BIP47)", "not_found": "لم يتم العثور على كود الدفع" } diff --git a/loc/bqi.json b/loc/bqi.json index 0c59e0d239..c520d6a486 100644 --- a/loc/bqi.json +++ b/loc/bqi.json @@ -233,12 +233,19 @@ "electrum_clear": "روفتن", "encrypt_decrypt": "رزم گوشایی جاگه زفت کردنی", "encrypt_title": "امنیت", + "encrypt_tstorage": "جاگه زفت کردنی", "encrypt_use": "{type} نه به کار بگر", "general": "پوی وولاتی", "general_adv_mode": "هالت پؽش رئڌه", "header": "سامووا", "language": "زۉ", + "last_updated": "ورۊ رسۊوی دیندایی", + "language_isRTL": "ره وندن دووارته BlueWallet سی انجوم آلشت کاریا ری زۉ الن وا انجوم بۊ.", + "license": "موجوز", + "lightning_error_lndhub_uri": "یۊآرآی LNDHub زبال نؽ", + "lightning_saved": "آلشت کاریا ایسا وه خۊوی زفت وابین.", "lightning_settings": "سامووا لایتنینگ", + "lightning_settings_explain": "سی منپیز وه گره LND خوت، LNDHub نه بپۊرن ۉ آدرسسه ایچونا منه سامووا بنه. ویرت بۊ که کیف پیلا وورکل وابیڌه دیندا زفت کردن آلشت کاریا وه LNDHub موشخس وابیڌه منپیز ابۊ.", "network": "شبکه", "network_electrum": "سرور الکترام", "notifications": "وارسۊویا", @@ -262,6 +269,7 @@ "details_copy": "لف گیری", "date": "ویرگار", "details_received": "گرؽڌه وابیڌه", + "transaction_saved": "زفت وابی", "pending": "مندیر سی زفت", "open_url_error": "نا مۉفق منه گۊشیڌن لینگ وا مۊرۊرگر پؽش فرز. مۊرۊرگر پؽش فرز خوته آلشت کو ۉ زه نۊ تفره کو." }, diff --git a/loc/ca.json b/loc/ca.json index baf48f80f5..f3f181af06 100644 --- a/loc/ca.json +++ b/loc/ca.json @@ -235,7 +235,6 @@ "cpfp_create": "Crear", "details_balance_hide": "Amaga el saldo", "details_balance_show": "Mostra el saldo", - "details_block": "Altura del bloc", "details_copy": "Copiar", "details_copy_amount": "Còpia la quantitat", "details_from": "De", @@ -243,7 +242,7 @@ "details_outputs": "Sortides", "date": "Data", "details_received": "Rebut", - "transaction_note_saved": "La nota de transacció s'ha desat correctament.", + "transaction_saved": "Desat", "details_show_in_block_explorer": "Mostrar en l'explorador de blocs", "details_title": "Transacció", "details_to": "A", @@ -293,6 +292,7 @@ "list_empty_txs1_lightning": "Els moneders Lightning poden ser usats per les seves transaccions diàries. Les comissions són baixes i els pagaments ràpids.", "list_latest_transaction": "última transacció", "list_long_choose": "Tria la foto", + "import_file": "Importar arxiu", "list_long_scan": "Escaneja el codi QR", "list_title": "moneders", "list_tryagain": "Torna-ho a provar", diff --git a/loc/cs_cz.json b/loc/cs_cz.json index b88c5164ad..ba5b3b7b65 100644 --- a/loc/cs_cz.json +++ b/loc/cs_cz.json @@ -125,7 +125,8 @@ "maxSats": "Maximální množství je {max} sats", "maxSatsFull": "Maximální částka je {max} sats nebo {currency} ", "minSats": "Minimální množství je {min} sats", - "minSatsFull": "Minimální částka je {min} sats nebo {currency} " + "minSatsFull": "Minimální částka je {min} sats nebo {currency} ", + "qrcode_for_the_address": "QR kód pro adresu" }, "send": { "provided_address_is_invoice": "Zdá se, že tato adresa je určena pro Lightning fakturu. Přejděte prosím do své Lightning peněženky, abyste mohli provést platbu této faktury.", @@ -166,6 +167,7 @@ "details_next": "Další", "details_no_signed_tx": "Vybraný soubor neobsahuje transakci, kterou lze importovat.", "details_note_placeholder": "Poznámka pro sebe", + "counterparty_label_placeholder": "Upravit jméno kontaktu", "details_scan": "Skenovat", "details_scan_hint": "Dvojitým klepnutím naskenujete nebo importujete cíl", "details_total_exceeds_balance": "Částka, kterou se snažíte odeslat, přesahuje dostupný zůstatek.", @@ -275,6 +277,7 @@ "encrypt_title": "Zabezpečení", "encrypt_tstorage": "Úložiště", "encrypt_use": "Použít {type}", + "encrypted_feature_disabled": "Tato funkce nemůže být použita, pokud je povoleno zašifrované úložiště.", "encrypt_use_expl": "{type} bude použit k potvrzení vaší identity před provedením transakce, odemknutím, exportem nebo smazáním peněženky. {type} nebude použit k odemknutí zašifrovaného úložiště.", "biometrics_fail": "Pokud {type} není povolen, nebo selže při odemykání, můžete jako alternativu použít přístupový kód vašeho zařízení.", "general": "Obecné", @@ -340,7 +343,6 @@ "cpfp_title": "Poplatek za popostrčení (CPFP)", "details_balance_hide": "Skrýt zůstatek", "details_balance_show": "Zobrazit zůstatek", - "details_block": "Výška bloku", "details_copy": "Zkopírovat", "details_copy_amount": "Zkopírovat částku", "details_copy_block_explorer_link": "Zkopírovat odkaz na průzkumník bloků", @@ -351,7 +353,7 @@ "details_outputs": "Výstupy", "date": "Datum", "details_received": "Přijato", - "transaction_note_saved": "Poznámka k transakci byla úspěšně uložena.", + "transaction_saved": "Uloženo", "details_show_in_block_explorer": "Zobrazit v průzkumníku bloků", "details_title": "Transakce", "details_to": "Výstup", @@ -372,6 +374,8 @@ "status_cancel": "Zrušit transakci", "transactions_count": "Počet transakcí", "txid": "ID transakce", + "from": "Od: {counterparty}", + "to": "Pro: {counterparty}", "updating": "Aktualizování…" }, "wallets": { @@ -449,9 +453,9 @@ "list_empty_txs2": "Začněte s peněženkou.", "list_empty_txs2_lightning": "\nChcete-li ji začít používat, klepněte na „Správa prostředků“ a doplňte zůstatek.", "list_latest_transaction": "Poslední transakce", - "list_ln_browser": "Prohlížeč LApp", "list_long_choose": "Vybrat fotku", "list_long_clipboard": "Kopírovat ze schránky", + "import_file": "Importovat soubor", "list_long_scan": "Naskenovat QR kód", "list_title": "Peněženky", "list_tryagain": "Zkuste to znovu", @@ -613,9 +617,23 @@ }, "bip47": { "payment_code": "Platební kód", - "payment_codes_list": "Seznam platebních kódů", - "who_can_pay_me": "Kdo mi může zaplatit:", + "my_payment_code": "Můj platební kód", + "contacts": "Kontakty", "purpose": "Opakovaně použitelný kód, který je možné sdílet (BIP47)", + "pay_this_contact": "Zaplatit tomuto kontaktu", + "rename_contact": "Přejmenovat kontakt", + "copy_payment_code": "Zkopírovat platební kód", + "copied": "Zkopírováno", + "rename": "Přejmenovat", + "provide_name": "Poskytněte nové jméno pro tento kontakt", + "add_contact": "Přidat kontakt", + "provide_payment_code": "Poskytnout platební kód", + "invalid_pc": "Neplatný platební kód", + "notification_tx_unconfirmed": "Oznamovací transakce ještě není potvrzena, počkejte prosím", + "failed_create_notif_tx": "Vytvoření on-chain transakce selhalo", + "onchain_tx_needed": "Je vyžadována on-chain transakce", + "notif_tx_sent": "Oznamovací transakce byla odeslána. Počkejte prosím, než bude potvrzena", + "notif_tx": "Oznamovací transakce", "not_found": "Platební kód nebyl nalezen" } } diff --git a/loc/cy.json b/loc/cy.json index 3f4c0c8970..464aa6cf94 100644 --- a/loc/cy.json +++ b/loc/cy.json @@ -148,6 +148,7 @@ "details_inputs": "Mewnbynau", "details_outputs": "Allbynau", "details_received": "Derbynwyd", + "transaction_saved": "Wedi Safio", "details_title": "Trafodyn", "details_to": "Allbwn", "pending": "Disgwyl", @@ -189,6 +190,7 @@ "list_latest_transaction": "Trafodyn Diweddaraf", "list_long_choose": "Dewis Llun", "list_long_clipboard": "Copio o'r Clipfwrdd", + "import_file": "Mewnforio ffeil", "list_title": "Waledi", "list_tryagain": "Trio eto", "select_wallet": "Dewis waled", diff --git a/loc/de_de.json b/loc/de_de.json index f8aa2528d1..7ee7126b7c 100644 --- a/loc/de_de.json +++ b/loc/de_de.json @@ -631,7 +631,7 @@ "notification_tx_unconfirmed": "Benachrichtigungstransaktion noch unbestätigt. Bitte warten", "failed_create_notif_tx": "On-Chain Transaktion konnte nicht in erstellt werden", "onchain_tx_needed": "On-Chain Transaktion benötigt.", - "notif_tx_sent" : "Benachrichtigungstransaktion ist gesendet. Auf Bestätigung warten.", + "notif_tx_sent": "Benachrichtigungstransaktion ist gesendet. Auf Bestätigung warten.", "notif_tx": "Benachrichtigungstransaktion", "not_found": "Zahlungscode nicht gefunden" } diff --git a/loc/el.json b/loc/el.json index 9b5207fecc..405044c54d 100644 --- a/loc/el.json +++ b/loc/el.json @@ -248,7 +248,7 @@ "details_from": "Εισερχόμενες διευθύνσεις", "date": "Ημερομηνία", "details_received": "Ελήφθη", - "transaction_note_saved": "Η σημείωση συναλλαγής δημιουργήθηκε με επιτυχία", + "transaction_saved": "Αποθηκεύτηκε", "details_show_in_block_explorer": "Προβολή στον block explorer", "details_title": "Συναλλαγή", "details_to": "Εξερχόμενες διευθύνσεις", @@ -368,8 +368,6 @@ }, "bip47": { "payment_code": "Κωδικός πληρωμής", - "payment_codes_list": "Λίστα κωδικών πληρωμής", - "who_can_pay_me": "Ποιος μπορεί να με πληρώσει:", "not_found": "Ο κωδικός πληρωμής δεν βρέθηκε" } } diff --git a/loc/es.json b/loc/es.json index d07f13693c..4a7f94a621 100644 --- a/loc/es.json +++ b/loc/es.json @@ -306,7 +306,6 @@ "cpfp_title": "Aumentar comisión (CPFP)", "details_balance_hide": "Esconder balance", "details_balance_show": "Mostrar balance", - "details_block": "Altura del bloque", "details_copy": "Copiar", "details_copy_amount": "Copiar cantidad", "details_copy_block_explorer_link": "Copiar el enlace del explorador de bloques", @@ -317,7 +316,7 @@ "details_outputs": "Outputs", "date": "Fecha", "details_received": "Recibido", - "transaction_note_saved": "La nota de la transacción ha sido guardada.", + "transaction_saved": "Guardado", "details_show_in_block_explorer": "Mostrar en explorador de bloques", "details_title": "Transaccion", "details_to": "Destino", @@ -405,9 +404,9 @@ "list_empty_txs2": "Empieza con tu cartera.", "list_empty_txs2_lightning": "\nPara comenzar a usarlo, toca en \"administrar fondos\" y añade algo de saldo.", "list_latest_transaction": "Última transacción", - "list_ln_browser": "Navegador LApp", "list_long_choose": "Elegir foto", "list_long_clipboard": "Copiar del portapapeles", + "import_file": "Importar archivo", "list_long_scan": "Escanear código QR", "list_title": "Carteras", "list_tryagain": "Inténtalo otra vez", diff --git a/loc/es_419.json b/loc/es_419.json index 2b1319c5e3..5ca8c4620f 100644 --- a/loc/es_419.json +++ b/loc/es_419.json @@ -455,6 +455,7 @@ "list_latest_transaction": "Última Transacción", "list_long_choose": "Elige una Foto", "list_long_clipboard": "Copiar desde el Portapapeles", + "import_file": "Importar Archivo", "list_long_scan": "Escanear Código QR", "list_title": "Billeteras", "list_tryagain": "Intenta otra vez", @@ -630,7 +631,7 @@ "notification_tx_unconfirmed": "La transacción de notificación aún no está confirmada, espera", "failed_create_notif_tx": "No se pudo crear una transacción en cadena", "onchain_tx_needed": "Se necesita transacción en cadena", - "notif_tx_sent" : "Transacción de notificación enviada. Espera a que se confirme", + "notif_tx_sent": "Transacción de notificación enviada. Espera a que se confirme", "notif_tx": "Transacción de notificación", "not_found": "Código de pago no encontrado" } diff --git a/loc/fa.json b/loc/fa.json index ad59bb76f6..76a59ed280 100644 --- a/loc/fa.json +++ b/loc/fa.json @@ -271,6 +271,7 @@ "language": "زبان", "last_updated": "آخرین به‌روزرسانی", "language_isRTL": "راه‌اندازی مجدد BlueWallet جهت اعمال تغییرات چینش زبان ضروری است.", + "license": "پروانه", "lightning_error_lndhub_uri": "یوآرآی LNDHub غیرمعتبر", "lightning_saved": "تغییرات شما با موفقیت ذخیره شدند.", "lightning_settings": "تنظیمات لایتنینگ", @@ -320,7 +321,6 @@ "cpfp_title": "افزایش کارمزد (CPFP)", "details_balance_hide": "پنهان‌کردن موجودی", "details_balance_show": "نمایش موجودی", - "details_block": "ارتفاع بلاک", "details_copy": "کپی", "details_copy_amount": "کپی مقدار", "details_copy_block_explorer_link": "کپی لینک مرورگر بلاک", @@ -331,7 +331,7 @@ "details_outputs": "خروجی‌ها", "date": "تاریخ", "details_received": "دریافت‌شده", - "transaction_note_saved": "یادداشت تراکنش با موفقیت ذخیره شد.", + "transaction_saved": "ذخیره شد", "details_show_in_block_explorer": "مشاهده در مرورگر بلاک", "details_title": "تراکنش", "details_to": "خروجی", @@ -412,7 +412,11 @@ "import_discovery_subtitle": "کیف پول پیداشده را انتخاب کنید", "import_discovery_derivation": "استفاده از مسیر اشتقاق دلخواه", "import_discovery_no_wallets": "کیف پولی یافت نشد.", + "import_derivation_found": "پیدا شد", + "import_derivation_found_not": "پیدا نشد", + "import_derivation_loading": "درحال‌بارگذاری…", "import_derivation_title": "مسیر اشتقاق", + "import_derivation_unknown": "نامشخص", "list_create_a_button": "هم‌اکنون اضافه کن", "list_create_a_wallet": "افزودن کیف پول", "list_empty_txs1": "تراکنش‌های شما در اینجا نمایش داده خواهند شد.", @@ -420,9 +424,9 @@ "list_empty_txs2": "با کیف پول خود شروع کنید.", "list_empty_txs2_lightning": "\nبرای شروع استفاده، روی «مدیریت دارایی» بزنید و موجودی خود را شارژ کنید.", "list_latest_transaction": "آخرین تراکنش", - "list_ln_browser": "مرورگر LApp", "list_long_choose": "انتخاب عکس", "list_long_clipboard": "کپی از کلیپ‌بورد", + "import_file": "واردکردن فایل", "list_long_scan": "اسکن کد QR", "list_title": "کیف پول‌ها", "list_tryagain": "دوباره امتحان کنید", @@ -438,7 +442,8 @@ "warning_do_not_disclose": "هشدار! فاش نکنید.", "add_ln_wallet_first": "ابتدا باید یک کیف پول لایتنینگ اضافه کنید.", "identity_pubkey": "هویت/کلید عمومی", - "xpub_title": "کلید XPUB کیف پول" + "xpub_title": "کلید XPUB کیف پول", + "search_wallets": "جستجوی کیف‌پول‌ها" }, "multisig": { "multisig_vault": "گاوصندوق", @@ -563,9 +568,13 @@ }, "bip47": { "payment_code": "کد پرداخت", - "payment_codes_list": "فهرست کدهای پرداخت", - "who_can_pay_me": "چه کسی می‌تواند به من پرداخت کند:", + "contacts": "مخاطبان", "purpose": "کد بازکاربردپذیر و قابل همرسانی (بیپ47)", + "pay_this_contact": "پرداخت به این مخاطب", + "copy_payment_code": "رونویسی کد پرداخت", + "copied": "رونویسی شد", + "rename": "ویرایش نام", + "add_contact": "افزودن مخاطب", "not_found": "کد پرداخت یافت نشد" } } diff --git a/loc/fi_fi.json b/loc/fi_fi.json index 9f9ab3a709..a6dab1f2bd 100644 --- a/loc/fi_fi.json +++ b/loc/fi_fi.json @@ -5,6 +5,7 @@ "continue": "Jatka", "clipboard": "Leikepöytä", "discard_changes": "Hylkää muutokset?", + "discard_changes_explain": "Sinulla on tallentamattomia muutoksia. Haluatko varmasti hylätä ne ja poistu näytöltä? ", "enter_password": "Anna salasana", "never": "ei koskaan", "of": "{number} / {total}", @@ -16,7 +17,16 @@ "seed": "Siemen", "success": "Onnistui", "wallet_key": "Lompakkoavain", - "invalid_animated_qr_code_fragment": "Virheellinen animoitu QRCode-fragmentti, yritä uudelleen." + "invalid_animated_qr_code_fragment": "Virheellinen animoitu QRCode-fragmentti, yritä uudelleen.", + "close": "Sulje", + "change_input_currency": "Vaihda lähdevaluutta", + "refresh": "Päivitä", + "more": "Lisää", + "pick_image": "Valitse kuva kirjastosta", + "pick_file": "Valitse tiedosto", + "enter_amount": "Syötä määrä", + "qr_custom_input_button": "Napauta 10 kertaa syöttääksesi halutun arvon", + "unlock": "Avaa lukitus" }, "alert": { "default": "Hälytys" @@ -54,6 +64,7 @@ "node_alias": "Solmun lempinimi", "expiresIn": "Vanhenee {time} minuutissa", "payButton": "Maksa", + "payment": "Maksu", "placeholder": "Lasku", "open_channel": "Avaa kanava", "funding_amount_placeholder": "Rahoitettava määrä, esimerkiksi 0.001", @@ -109,11 +120,13 @@ "details_create": "Luo", "details_label": "Selite", "details_setAmount": "Vastaanotettava summa", + "details_share": "Jaa...", "header": "Vastaanota", "maxSats": "Enimmäismäärä on {max} satsia", "maxSatsFull": "Enimmäismäärä on {max} satsia tai {valuutta}", "minSats": "Vähimmäismäärä on {min} satsia", - "minSatsFull": "Vähimmäismäärä on {min} satsia tai {valuutta}" + "minSatsFull": "Vähimmäismäärä on {min} satsia tai {valuutta}", + "qrcode_for_the_address": "QR-koodi osoitteelle" }, "send": { "provided_address_is_invoice": "Tämä osoite vaikuttaa olevan Salamalasku. Maksun suorittamiseksi, siirry Salamalompakkoosi.", @@ -154,6 +167,7 @@ "details_next": "Seuraava", "details_no_signed_tx": "Valittu tiedosto ei sisällä tuotavaa siirtotapahtumaa.", "details_note_placeholder": "muistiinpano itselle", + "counterparty_label_placeholder": "Muokkaa yhteystiedon nimeä", "details_scan": "Skannaa", "details_scan_hint": "Scannaa tai tuo tupla-napauttamalla", "details_total_exceeds_balance": "Lähetettävä summa ylittää katteen", @@ -198,6 +212,7 @@ "reset_amount_confirm": "Haluaisitko nollata määrän?", "success_done": "Valmis", "txSaved": "Siirtotapahtumatiedosto ({filePath}) on tallennettu Lataukset-kansioon.", + "file_saved_at_path": "Tiedosto ({fileName}) on tallennettu Lataukset -kansioosi.", "problem_with_psbt": "Ongelma PSBT:n kanssa" }, "settings": { @@ -272,6 +287,7 @@ "language": "Kieli", "last_updated": "Päivitetty viimeksi", "language_isRTL": "BlueWallet on käynnistettävä uudelleen, jotta kielisuuntaus tulee voimaan.", + "license": "Lisenssi", "lightning_error_lndhub_uri": "Virheellinen LNDHub URI", "lightning_saved": "Muutoksesi on tallennettu onnistuneesti", "lightning_settings": "Salama-asetukset", @@ -324,7 +340,6 @@ "cpfp_title": "Nosta siirtomaksua (CPFP)", "details_balance_hide": "Piilota Saldo", "details_balance_show": "Näytä Saldo", - "details_block": "Lohkon järjestysnumero", "details_copy": "Kopioi", "details_copy_amount": "Kopioi määrä", "details_copy_block_explorer_link": "Kopioi linkki lohkoketjuselaimeen", @@ -335,7 +350,7 @@ "details_outputs": "Ulostulot", "date": "Päivämäärä", "details_received": "Vastaanotettu", - "transaction_note_saved": "Siirtotapahtumailmoitus on tallennettu.", + "transaction_saved": "Tallennettu", "details_show_in_block_explorer": "Näytä lohkoketjuselaimessa", "details_title": "Siirtotapahtuma", "details_to": "Ulostulo", @@ -356,6 +371,8 @@ "status_cancel": "Peruuta Siirtotapahtuma", "transactions_count": "Siirtotapahtumien määrä", "txid": "Siirtotapahtuman tunnus", + "from": "Lähettäjä: {counterparty}", + "to": "Vastaanottaja: {counterparty}", "updating": "Päivitetään..." }, "wallets": { @@ -386,6 +403,7 @@ "details_delete": "Poista", "details_delete_wallet": "Poista lompakko", "details_derivation_path": "johdantopolku", + "details_display": "Näytä kotinäkymässä", "details_export_backup": "Vie / varmuuskopioi", "details_export_history": "Vie historia CSV:ksi", "details_master_fingerprint": "Pää sormenjälki", @@ -432,9 +450,9 @@ "list_empty_txs2": "Aloita lompakostasi. ", "list_empty_txs2_lightning": "Aloita lompakon käyttäminen napsauttamalla \"hallinnoi varoja\" ja lisää saldoasi.\n", "list_latest_transaction": "Viimeisin Siirtotapahtuma", - "list_ln_browser": "LApp-selain", "list_long_choose": "Valitse Kuva", "list_long_clipboard": "Kopioi Leikepöydältä", + "import_file": "Tuo tiedosto", "list_long_scan": "Skannaa QR-koodi", "list_title": "lompakot", "list_tryagain": "Yritä uudelleen", @@ -450,7 +468,8 @@ "warning_do_not_disclose": "Varoitus! Älä paljasta", "add_ln_wallet_first": "Sinun on ensin lisättävä Salamalompakko.", "identity_pubkey": "Tunnus Pubkey", - "xpub_title": "lompakon XPUB" + "xpub_title": "lompakon XPUB", + "search_wallets": "Etsi lompakoista" }, "multisig": { "multisig_vault": "Vault", @@ -463,6 +482,7 @@ "fee_btc": "{number} BTC", "confirm": "Vahvista", "header": "Lähetä", + "share": "Jaa...", "view": "Näytä", "manage_keys": "Hallitse Avaimia", "how_many_signatures_can_bluewallet_make": "kuinka monta allekirjoitusta BlueWallet voi tehdä", @@ -530,6 +550,9 @@ "no_wallet_owns_address": "Mikään käytettävissä olevista lompakoista ei omista annettua osoitetta.", "view_qrcode": "Näytä QR-koodi" }, + "autofill_word": { + "generate_word": "Muodosta viimeinen sana" + }, "cc": { "change": "vaihto", "coins_selected": "Kolikot valittu ({number})", @@ -550,6 +573,7 @@ "sats": "sattia" }, "addresses": { + "copy_private_key": "Kopio yksityinen avain", "sign_title": "Allekirjoita/Varmenna viesti", "sign_help": "Täällä voit luoda tai varmentaa Bitcoin-osoitteeseen perustuvan kryptografisen allekirjoituksen.", "sign_sign": "Allekirjoita", @@ -583,8 +607,11 @@ }, "bip47": { "payment_code": "Maksukoodi", - "payment_codes_list": "Maksukoodiluettelo", - "who_can_pay_me": "Kuka voi maksaa minulle:", - "purpose": "Uudelleenkäytettävä ja jaettavissa oleva koodi (BIP47)" + "contacts": "Yhteystiedot", + "purpose": "Uudelleenkäytettävä ja jaettavissa oleva koodi (BIP47)", + "rename_contact": "Nimeä uudelleen yhteystieto", + "copied": "Kopioitu", + "rename": "Nimeä uudelleen", + "add_contact": "Lisää yhteystieto" } } diff --git a/loc/fr_fr.json b/loc/fr_fr.json index a8191da24f..9e099bba04 100644 --- a/loc/fr_fr.json +++ b/loc/fr_fr.json @@ -324,7 +324,6 @@ "cpfp_title": "Frais de propulsion (CPFP)", "details_balance_hide": "Cacher le solde", "details_balance_show": "Montrer le solde", - "details_block": "Hauteur de bloc", "details_copy": "Copier", "details_copy_amount": "Copier le montant", "details_copy_block_explorer_link": "Copier le lien Block Explorer", @@ -334,7 +333,7 @@ "details_inputs": "Inputs", "details_outputs": "Outputs", "details_received": "Reçu", - "transaction_note_saved": "La note de transaction a été enregistrée avec succès.", + "transaction_saved": "Enregistré", "details_show_in_block_explorer": "Afficher dans le \"block explorer\"", "details_title": "Transaction", "details_to": "À", @@ -429,9 +428,9 @@ "list_empty_txs2": "Commencez avec votre portefeuille.", "list_empty_txs2_lightning": "\nPour commencer à l'utiliser taper sur \"Gérer les fonds\" et alimentez votre solde.", "list_latest_transaction": "dernière transaction", - "list_ln_browser": "Selectionneur LApp", "list_long_choose": "Choisir une photo", "list_long_clipboard": "Copier depuis le presse-papier", + "import_file": "Importer le fichier", "list_long_scan": "Scanner le QR Code", "list_title": "portefeuilles", "list_tryagain": "Réessayer", diff --git a/loc/he.json b/loc/he.json index c0eaddf91c..09b0b4d3f4 100644 --- a/loc/he.json +++ b/loc/he.json @@ -336,7 +336,6 @@ "cpfp_title": "הקפץ עמלה (CPFP)", "details_balance_hide": "הסתרת מאזן", "details_balance_show": "הצגת מאזן", - "details_block": "גובה הבלוק", "details_copy": "העתקה", "details_copy_amount": "העתקת סכום", "details_copy_block_explorer_link": "העתקת קישור סייר בלוקים", @@ -347,7 +346,7 @@ "details_outputs": "פלטים", "date": "תאריך", "details_received": "התקבל", - "transaction_note_saved": "הערת פעולה נשמרה בהצלחה.", + "transaction_saved": "נשמר", "details_show_in_block_explorer": "צפייה בסייר בלוקים", "details_title": "פעולה", "details_to": "פלט", @@ -446,6 +445,7 @@ "list_latest_transaction": "פעולה אחרונה", "list_long_choose": "בחר תמונה", "list_long_clipboard": "העתקה מלוח", + "import_file": "יבוא קובץ", "list_long_scan": "סריקת קוד QR", "list_title": "ארנקים", "list_tryagain": "נסו שוב", @@ -599,8 +599,6 @@ }, "bip47": { "payment_code": "קוד תשלום", - "payment_codes_list": "רשימת קודי תשלום", - "who_can_pay_me": "מי יכול לשלם לי:", "purpose": "קוד רב-פעמי ובר-שיתוף (BIP47)", "not_found": "קוד תשלום לא נמצא" } diff --git a/loc/hu_hu.json b/loc/hu_hu.json index 9c8d10e31b..a3965c07a3 100644 --- a/loc/hu_hu.json +++ b/loc/hu_hu.json @@ -317,7 +317,6 @@ "cpfp_title": "Kiváltási díj (CPFP)", "details_balance_hide": "Egyenleg elrejtése", "details_balance_show": "Egyenleg mutatása", - "details_block": "Blokkszámláló", "details_copy": "Másolás", "details_copy_amount": "Mennyiség Másolása", "details_copy_block_explorer_link": "Blokk Böngésző Link Másolása", @@ -327,7 +326,7 @@ "details_inputs": "Bejövő utalások", "details_outputs": "Kimenő utalások", "details_received": "Fogadott", - "transaction_note_saved": "Tranzakciós megjegyzés sikeresen elmentve.", + "transaction_saved": "Elmentve", "details_show_in_block_explorer": "Mutasd a block explorerben", "details_title": "Tranzakció", "details_to": "Kimenő utalás", @@ -421,9 +420,9 @@ "list_empty_txs2": "Kezd a tárcáddal.", "list_empty_txs2_lightning": "\nA kezdéshez kattints a \"Kezelés\"-re, és töltsd fel az egyenleged.", "list_latest_transaction": "utolsó tranzakció", - "list_ln_browser": "LApp Böngésző", "list_long_choose": "Válassz fényképet", "list_long_clipboard": "Másolás vágólapról", + "import_file": "fájl importálása", "list_long_scan": "QR kód szkennelése", "list_title": "tárcák", "list_tryagain": "Próbáld újra", diff --git a/loc/id_id.json b/loc/id_id.json index 8d6f24a422..c332f1d45d 100644 --- a/loc/id_id.json +++ b/loc/id_id.json @@ -292,7 +292,7 @@ "details_inputs": "Input", "date": "Tanggal", "details_received": "Diterima", - "transaction_note_saved": "Catatan transaksi telah berhasil tersimpan.", + "transaction_saved": "Tersimpan", "details_show_in_block_explorer": "Tampilkan di block explorer", "details_title": "Transaksi", "pending": "tertunda", diff --git a/loc/it.json b/loc/it.json index 07624b57d0..ceb0aaf052 100644 --- a/loc/it.json +++ b/loc/it.json @@ -316,7 +316,6 @@ "cpfp_title": "Aumenta la commissione (CPFP)", "details_balance_hide": "Nascondi il saldo", "details_balance_show": "Mostra il saldo", - "details_block": "Altezza del blocco", "details_copy": "Copia", "details_copy_amount": "Copia importo", "details_copy_block_explorer_link": "Copia link del Block Explorer", @@ -327,7 +326,7 @@ "details_outputs": "Output", "date": "Data", "details_received": "Ricevuto", - "transaction_note_saved": "La transazione è stata registrata con successo.", + "transaction_saved": "Salvato", "details_show_in_block_explorer": "Mostra sul block explorer", "details_title": "Transazione", "details_to": "A", @@ -416,7 +415,6 @@ "list_empty_txs2": "Inizia con il tuo wallet.", "list_empty_txs2_lightning": "\nPer iniziare ad usarlo, seleziona Gestisci Fondi e ricarica il tuo saldo.", "list_latest_transaction": "Transazioni recenti", - "list_ln_browser": "Browser LApp", "list_long_choose": "Scegli foto", "list_long_clipboard": "Copia dagli appunti", "list_long_scan": "Scansiona un codice QR", @@ -559,8 +557,6 @@ }, "bip47": { "payment_code": "Codice di pagamento", - "payment_codes_list": "Lista dei codici di pagamento", - "who_can_pay_me": "Chi può pagarmi:", "purpose": "Codice (BIP47) riutilizzabile e condivisibile", "not_found": "Codice di pagamento non trovato" } diff --git a/loc/jp_jp.json b/loc/jp_jp.json index 7e65e68178..0f6970cd44 100644 --- a/loc/jp_jp.json +++ b/loc/jp_jp.json @@ -167,6 +167,7 @@ "details_next": "次", "details_no_signed_tx": "選択したファイルには、インポート可能なトランザクションが含まれていません。", "details_note_placeholder": "ラベル", + "counterparty_label_placeholder": "連絡先の名前を編集", "details_scan": "読取り", "details_scan_hint": "ダブルタップして宛先をスキャンまたはインポート", "details_total_exceeds_balance": "送金額が利用可能残額を超えています。", @@ -276,6 +277,7 @@ "encrypt_title": "セキュリティ", "encrypt_tstorage": "ストレージ", "encrypt_use": "{type} を使う", + "encrypted_feature_disabled": "ストレージの暗号化が有効の場合この機能は使えません。", "encrypt_use_expl": "{type} は、トランザクションの実行、ウォレットのロック解除、エクスポート、または削除を行う前の本人確認に使用されます。{type} は暗号化されたストレージのロック解除には使用されません。", "biometrics_fail": "もし {type} が有効でない、または解除に失敗した場合、デバイスのパスコードを代わりに使うことができます。", "general": "一般情報", @@ -341,7 +343,6 @@ "cpfp_title": "バンプ費用 (CPFP)", "details_balance_hide": "残高を隠す", "details_balance_show": "残高を表示", - "details_block": "ブロック高", "details_copy": "コピー", "details_copy_amount": "額をコピー", "details_copy_block_explorer_link": "ブロックエクスプローラーのリンクをコピー", @@ -352,7 +353,7 @@ "details_outputs": "アウトプット", "date": "日付", "details_received": "受取り済", - "transaction_note_saved": "トランザクションノートが正常に保存されました。", + "transaction_saved": "保存済", "details_show_in_block_explorer": "Block Explorer で表示", "details_title": "取引", "details_to": "送り先", @@ -373,6 +374,8 @@ "status_cancel": "トランザクションをキャンセル", "transactions_count": "トランザクションカウント", "txid": "トランザクションID", + "from": "From: {counterparty}", + "to": "To: {counterparty}", "updating": "更新中…" }, "wallets": { @@ -452,6 +455,7 @@ "list_latest_transaction": "最新の取引", "list_long_choose": "写真選択", "list_long_clipboard": "クリップボードからコピー", + "import_file": "インポートファイル", "list_long_scan": "QRコードをスキャン", "list_title": "ウォレット", "list_tryagain": "再度試す", @@ -613,9 +617,23 @@ }, "bip47": { "payment_code": "支払コード", - "payment_codes_list": "支払コードリスト", - "who_can_pay_me": "あなたに支払いできる人:", + "my_payment_code": "自分の支払いコード", + "contacts": "連絡先", "purpose": "再利用・共有可能なコード (BIP47)", + "pay_this_contact": "この連絡先に支払う", + "rename_contact": "連絡先をリネーム", + "copy_payment_code": "支払いコードをコピー", + "copied": "コピー済み", + "rename": "リネーム", + "provide_name": "連絡先に新しい名前を付ける", + "add_contact": "連絡先を追加", + "provide_payment_code": "支払いコードを渡す", + "invalid_pc": "無効な支払いコード", + "notification_tx_unconfirmed": "通知トランザクションが承認されていません、お待ちください", + "failed_create_notif_tx": "チェーン上のトランザクションの作成に失敗しました", + "onchain_tx_needed": "チェーン上のトランザクションが必要です", + "notif_tx_sent": "通知トランザクションを送りました。承認をお待ちください", + "notif_tx": "通知トランザクション", "not_found": "支払コードが見つかりません" } } diff --git a/loc/kk@Cyrl.json b/loc/kk@Cyrl.json index 8943075c8a..f79fc0ffc4 100644 --- a/loc/kk@Cyrl.json +++ b/loc/kk@Cyrl.json @@ -90,7 +90,6 @@ }, "bip47": { "payment_code": "Төлем коды", - "payment_codes_list": "Төлем код тізбесі", "not_found": "Төлем коды табылмады" } } diff --git a/loc/ko_KR.json b/loc/ko_KR.json index d0522216e8..9991899f2b 100644 --- a/loc/ko_KR.json +++ b/loc/ko_KR.json @@ -300,7 +300,6 @@ "cpfp_title": "급행 수수료(CPFP)", "details_balance_hide": "잔고 감추기", "details_balance_show": "잔고 보여주기", - "details_block": "블록 높이", "details_copy": "복사", "details_copy_amount": "복사 금액", "details_copy_block_explorer_link": "블록 익스플로러 링크 복사하기", @@ -310,7 +309,7 @@ "details_inputs": "입력", "details_outputs": "출력", "details_received": "받기 완료", - "transaction_note_saved": "거래 노트가 성공적으로 저장되었습니다.", + "transaction_saved": "저장됨", "details_show_in_block_explorer": "블록 익스플로러에서 보기", "details_title": "트랜잭션", "details_to": "출력", @@ -396,9 +395,9 @@ "list_empty_txs2": "사용자 지갑으로 시작", "list_empty_txs2_lightning": "\n사용하시려면 기금관리를 탭하신다음 잔고를 더해 주세요.", "list_latest_transaction": "최근 트랜잭션", - "list_ln_browser": "랩 브라우저", "list_long_choose": "사진 선택하기", "list_long_clipboard": "클립보드에서 복사", + "import_file": "화일 들여오기", "list_long_scan": "QR 코드 스캔", "list_title": "지갑", "list_tryagain": "다시 시도하기", diff --git a/loc/ms.json b/loc/ms.json index 7d59f7ec1a..fcfe9aae0c 100644 --- a/loc/ms.json +++ b/loc/ms.json @@ -283,13 +283,12 @@ "cpfp_title": "Tambah Yuran (CPFP)", "details_balance_hide": "Sorok Baki", "details_balance_show": "Papar Baki", - "details_block": "Ketinggian Bongkah", "details_copy": "Salin", "details_from": "Masukan", "details_inputs": "Masukan", "details_outputs": "Keluaran", "details_received": "Diterima", - "transaction_note_saved": "Nota urus niaga berjaya disimpan.", + "transaction_saved": "Disimpan", "details_show_in_block_explorer": "Lihat di Penjelajah Bongkah.", "details_title": "Urus niaga", "details_to": "Keluaran", @@ -365,9 +364,9 @@ "list_empty_txs2": "Mulakan dengan dompet anda.", "list_empty_txs2_lightning": "\nUntuk mula menggunakan, ketik pada Uruskan Wang dan tambah nilai pada baki anda.", "list_latest_transaction": "Urus Niaga Terkini", - "list_ln_browser": "Pelayar LApp", "list_long_choose": "Pilih Gambar", "list_long_clipboard": "Salin dari Papan Sepit", + "import_file": "Pindah Masuk Fail", "list_long_scan": "Imbas Kod QR", "list_title": "Dompet", "list_tryagain": "Cuba lagi", diff --git a/loc/nb_no.json b/loc/nb_no.json index 101c8b3387..3ba32eb8ae 100644 --- a/loc/nb_no.json +++ b/loc/nb_no.json @@ -302,7 +302,6 @@ "cpfp_title": "Betal høyere avgift (CPFP)", "details_balance_hide": "Gjem Balanse", "details_balance_show": "Vis Balanse", - "details_block": "Blokkhøyde", "details_copy": "Kopier", "details_copy_amount": "Kopier Beløp", "details_copy_block_explorer_link": "Kopier Block Explorer-lenken", @@ -312,7 +311,7 @@ "details_inputs": "Inndata", "details_outputs": "Utdata", "details_received": "Mottatt", - "transaction_note_saved": "Transaksjonsnotatet er lagret.", + "transaction_saved": "Lagret", "details_show_in_block_explorer": "Vis i Block Explorer", "details_title": "Transaksjon", "details_to": "Utdata", @@ -399,9 +398,9 @@ "list_empty_txs2": "Start med lommeboken din.", "list_empty_txs2_lightning": "\nFor å begynne å bruke den, trykk på Administrer Midler og fyll på saldoen.", "list_latest_transaction": "Siste Transaksjon", - "list_ln_browser": "LApp-nettleser", "list_long_choose": "Velg Bilde", "list_long_clipboard": "Kopier fra utklippstavlen", + "import_file": "Importer Fil", "list_long_scan": "Skann QR-kode", "list_title": "Lommebøker", "list_tryagain": "Prøv igjen", diff --git a/loc/ne.json b/loc/ne.json index 928e40ff67..3d806d840e 100644 --- a/loc/ne.json +++ b/loc/ne.json @@ -273,6 +273,7 @@ "details_copy_note": "नोट कापी", "date": "मिति", "details_received": "प्राप्त भयो", + "transaction_saved": "बचत गरियो", "details_title": "लेनदेन", "pending": "पेनदिंग", "list_title": "लेनदेन", @@ -403,8 +404,6 @@ }, "bip47": { "payment_code": "भुक्तानी कोड", - "payment_codes_list": "भुक्तानी कोड सूची", - "who_can_pay_me": "कसले मलाई तिर्न सक्छ:", "not_found": "भुक्तानी कोड फेला परेन" } } diff --git a/loc/nl_nl.json b/loc/nl_nl.json index 55684a58d7..d90de91fa5 100644 --- a/loc/nl_nl.json +++ b/loc/nl_nl.json @@ -306,7 +306,6 @@ "cpfp_title": "Bumb fee (CPFP)", "details_balance_hide": "Verberg saldo", "details_balance_show": "Toon saldo", - "details_block": "Blokhoogte", "details_copy": "Kopiëren", "details_copy_amount": "Kopieer aantal", "details_copy_block_explorer_link": "Kopieer blok explorer Link", @@ -316,7 +315,7 @@ "details_inputs": "Inputs", "details_outputs": "Outputs", "details_received": "Ontvangen", - "transaction_note_saved": "Transactie notitie is succesvol opgeslagen.", + "transaction_saved": "Opgeslagen", "details_show_in_block_explorer": "Weergeven in block explorer", "details_title": "Transacties", "details_to": "Uitvoer", @@ -400,9 +399,9 @@ "list_empty_txs2": "Begin met uw wallet.", "list_empty_txs2_lightning": "\nOm het te gebruiken, tikt u op \"tegoeden beheren\" en laadt u uw saldo op.", "list_latest_transaction": "Laatste transactie", - "list_ln_browser": "LApp Browser", "list_long_choose": "Kies foto", "list_long_clipboard": "Kopiëren van klembord", + "import_file": "Importeer bestand", "list_long_scan": "Scan QR-code", "list_title": "Wallets", "list_tryagain": "Probeer opnieuw", diff --git a/loc/pl.json b/loc/pl.json index 1b8025fee5..9959b0ca58 100644 --- a/loc/pl.json +++ b/loc/pl.json @@ -340,7 +340,6 @@ "cpfp_title": "Zwiększ opłatę (CPFP)", "details_balance_hide": "Ukryj Saldo", "details_balance_show": "Pokaż Saldo", - "details_block": "Number bloku", "details_copy": "Kopiuj", "details_copy_amount": "Kopiuj kwotę", "details_copy_block_explorer_link": "Kopiuj link do eksploratora bloków", @@ -351,7 +350,7 @@ "details_outputs": "Wyjścia", "date": "Data", "details_received": "Otrzymano", - "transaction_note_saved": "Transakcja została pomyślnie zapisana.", + "transaction_saved": "Zapisano", "details_show_in_block_explorer": "Zobacz w eksploratorze bloków", "details_title": "Transakcja", "details_to": "Wyjście", @@ -451,6 +450,7 @@ "list_latest_transaction": "Ostatnia transakcja", "list_long_choose": "Wybierz zdjęcie", "list_long_clipboard": "Kopiuj ze schowka", + "import_file": "Importuj plik", "list_long_scan": "Zeskanuj kod QR", "list_title": "Portfele", "list_tryagain": "Spróbuj ponownie", @@ -612,8 +612,6 @@ }, "bip47": { "payment_code": "Kod płatności", - "payment_codes_list": "Lista kodów płatności", - "who_can_pay_me": "Kto może mi płacić:", "purpose": "Kod wielokrotnego użytku możliwy do udostępnienia (BIP47)", "not_found": "Kod płatności nie znaleziony" } diff --git a/loc/pt_br.json b/loc/pt_br.json index 4f44171492..fb6773bcbc 100644 --- a/loc/pt_br.json +++ b/loc/pt_br.json @@ -125,7 +125,8 @@ "maxSats": "O Valor máximo é de {max} sats", "maxSatsFull": "O valor máximo é de {max} sats ou {currency}", "minSats": "O valor mínimo é de {min} sats", - "minSatsFull": "O valor mínimo é de {min} sats ou {currency}" + "minSatsFull": "O valor mínimo é de {min} sats ou {currency}", + "qrcode_for_the_address": "QR Code para o Endereço" }, "send": { "provided_address_is_invoice": "Esse tipo de endereço se parece com uma fatura da Lightning. Por favor, acesse a sua carteira Lightning para realizar o pagamento dessa fatura.", @@ -340,7 +341,6 @@ "cpfp_title": "Aumento de taxa (CPFP)", "details_balance_hide": "Esconder Saldo", "details_balance_show": "Mostrar Saldo", - "details_block": "Altura dos Blocos", "details_copy": "Copiar", "details_copy_amount": "Copiar Quantia", "details_copy_block_explorer_link": "Copiar Link do Explorador de Blocos", @@ -351,7 +351,7 @@ "details_outputs": "Saídas", "date": "Data", "details_received": "Recebido", - "transaction_note_saved": "A anotação da transação foi salva com sucesso.", + "transaction_saved": "Salvo", "details_show_in_block_explorer": "Ver no Explorador de Blocos", "details_title": "Transação", "details_to": "Saída", @@ -451,6 +451,7 @@ "list_latest_transaction": "Transação mais recente", "list_long_choose": "Escolher foto", "list_long_clipboard": "Copiar da área de transferência", + "import_file": "Importar arquivo", "list_long_scan": "Leia o código QR", "list_title": "Carteiras", "list_tryagain": "Tente novamente", @@ -612,8 +613,6 @@ }, "bip47": { "payment_code": "Código de pagamento", - "payment_codes_list": "Lista de códigos de pagamento", - "who_can_pay_me": "Quem pode me pagar:", "purpose": "Código para compartilhar (BIP47)", "not_found": "Código de pagamento não encontrado" } diff --git a/loc/pt_pt.json b/loc/pt_pt.json index ba6ddd9774..f8c09fcc01 100644 --- a/loc/pt_pt.json +++ b/loc/pt_pt.json @@ -258,7 +258,6 @@ "cpfp_title": "Aumento de taxa (CPFP)", "details_balance_hide": "Esconder Saldo", "details_balance_show": "Mostrar Saldo", - "details_block": "Block Height", "details_copy": "Copiar", "details_copy_amount": "Copiar montante", "details_copy_note": "Copiar nota", @@ -268,7 +267,7 @@ "details_outputs": "Outputs", "date": "Data", "details_received": "Recebido", - "transaction_note_saved": "Nota de transação salva com sucesso.", + "transaction_saved": "Guardado", "details_show_in_block_explorer": "Mostrar no block explorer", "details_title": "detalhes", "details_to": "Para", @@ -344,6 +343,7 @@ "list_latest_transaction": "últimas transacções", "list_long_choose": "Escolher Foto", "list_long_clipboard": "Copiar da área de transferência", + "import_file": "Importar ficheiro", "list_long_scan": "Leia o código QR", "list_title": "carteiras", "list_tryagain": "Tente novamente", diff --git a/loc/ro.json b/loc/ro.json index 846a4a7dd4..cfd8be34ce 100644 --- a/loc/ro.json +++ b/loc/ro.json @@ -287,7 +287,6 @@ "cpfp_title": "Crește comisionul (CPFP)", "details_balance_hide": "Ascunde balanța", "details_balance_show": "Afișează balanța", - "details_block": "Block Height", "details_copy": "Copiază", "details_copy_amount": "Copiază sumă", "details_copy_block_explorer_link": "Copiază link-ul block explorer-ului.", @@ -296,7 +295,7 @@ "details_inputs": "Input-uri", "details_outputs": "Output-uri", "details_received": "Primit", - "transaction_note_saved": "Notița tranzacției a fost salvată cu succes.", + "transaction_saved": "Salvat", "details_show_in_block_explorer": "Afișează în Block Explorer", "details_title": "Tranzacție", "details_to": "Output", @@ -373,9 +372,9 @@ "list_empty_txs2": "Pornește cu portofelul tău.", "list_empty_txs2_lightning": "\nPentru a începe să utilizezi, apasă pe Administrează Fonduri și încarcă balanța.", "list_latest_transaction": "Ultima tranzacție", - "list_ln_browser": "Browser LApp", "list_long_choose": "Alege foto", "list_long_clipboard": "Copiază din clipboard", + "import_file": "Importă fișier", "list_long_scan": "Scaneză cod QR", "list_title": "Portofele", "list_tryagain": "Încearcă din nou", diff --git a/loc/ru.json b/loc/ru.json index c858b0202a..c694f30e52 100644 --- a/loc/ru.json +++ b/loc/ru.json @@ -332,7 +332,6 @@ "cpfp_title": "Повысить комиссию (CPFP)", "details_balance_hide": "Скрыть баланс", "details_balance_show": "Показать баланс", - "details_block": "Номер Блока", "details_copy": "Копировать", "details_copy_amount": "Копировать Сумму", "details_copy_block_explorer_link": "Копировать ссылку на обозреватель блоков", @@ -343,7 +342,7 @@ "details_outputs": "Выходы", "date": "Дата", "details_received": "Получена", - "transaction_note_saved": "Заметка о транзакции успешно сохранена.", + "transaction_saved": "Сохранено", "details_show_in_block_explorer": "Показать транзакцию в блокчейне", "details_title": "Детали транзакции", "details_to": "Кому", @@ -440,9 +439,9 @@ "list_empty_txs2": "Добавьте кошелёк.", "list_empty_txs2_lightning": "\nДля начала использования нажмите \"Мои средства\" и пополните баланс.", "list_latest_transaction": "Последняя транзакция", - "list_ln_browser": "Лайтнинг браузер", "list_long_choose": "Выбрать фото", "list_long_clipboard": "Вставить из буфера обмена", + "import_file": "Импортировать файл", "list_long_scan": "Сканировать QR-код", "list_title": "Кошельки", "list_tryagain": "Попробовать еще раз", @@ -598,8 +597,6 @@ }, "bip47": { "payment_code": "Код Оплаты", - "payment_codes_list": "Список Кодов Оплаты", - "who_can_pay_me": "Кто может мне заплатить:", "purpose": "Многоразовый и общий код (BIP47)", "not_found": "Код оплаты не найден" } diff --git a/loc/si_LK.json b/loc/si_LK.json index 76bc375bdf..09d6a2e3f0 100644 --- a/loc/si_LK.json +++ b/loc/si_LK.json @@ -298,7 +298,6 @@ "cpfp_title": "බම්ප් ගාස්තුව (CPFP)", "details_balance_hide": "Hide Balance", "details_balance_show": "ශේෂය පෙන්වන්න", - "details_block": "උස අවහිර කරන්න", "details_copy": "පිටපත් කරන්න", "details_copy_amount": "ප්‍රමාණය පිටපත් කරන්න", "details_copy_block_explorer_link": "බ්ලොක් එක්ස්ප්ලෝරර් සම්බන්ධකය පිටපත් කරන්න", @@ -308,7 +307,7 @@ "details_inputs": "යෙදවුම්", "details_outputs": "ප්‍රතිදාන", "details_received": "ලැබුණි", - "transaction_note_saved": "ගනුදෙනු සටහන සාර්ථකව සුරකින ලදි.", + "transaction_saved": "සුරකින ලදි", "details_show_in_block_explorer": "බ්ලොක් එක්ස්ප්ලෝරර් හි බලන්න", "details_title": "ගනුදෙනුව", "details_to": "ප්‍රතිදානය", @@ -394,9 +393,9 @@ "list_empty_txs2": "ඔබේ පසුම්බිය සමඟ ආරම්භ කරන්න.", "list_empty_txs2_lightning": "\nඑය භාවිතා කිරීම ආරම්භ කිරීම සඳහා කළමනාකරණය කළමනාකරණය කර ඔබේ ශේෂය ඉහළ නැංවීමට තට්ටු කරන්න.", "list_latest_transaction": "නවතම ගනුදෙනුව", - "list_ln_browser": "LApp බ්‍රව්සරය", "list_long_choose": "ඡායාරූපය තෝරන්න", "list_long_clipboard": "පසුරු පුවරුවෙන් පිටපත් කරන්න", + "import_file": "ආයාත ගොනුව", "list_long_scan": "QR කේතය පරිලෝකනය කරන්න", "list_title": "පසුම්බි", "list_tryagain": "නැවත උත්සාහ කරන්න", diff --git a/loc/sk_sk.json b/loc/sk_sk.json index 2feb6776aa..84147c1d57 100644 --- a/loc/sk_sk.json +++ b/loc/sk_sk.json @@ -171,12 +171,12 @@ "cpfp_exp": "Vytvoríme novú transakciu, ktorá ako vstup použije výstup z Vašej nepotvrdenej transakcie. Súčet poplatkov bude vyšší, preto sa transakcie overia skôr. Tento postup sa volá CPFP - Child Pays For Parent.", "cpfp_no_bump": "Poplatok za túto transakciu sa nedá navýšiť", "cpfp_title": "Navýšiť poplatok za transakciu (CPFP)", - "details_block": "Výška bloku", "details_copy": "Kopírovať", "details_from": "Vstup", "details_inputs": "Vstupy", "details_outputs": "Výstupy", "details_received": "Prijaté", + "transaction_saved": "Uložené", "details_show_in_block_explorer": "Ukázať v block exploreri", "details_title": "Transakcia", "details_to": "Výstup", diff --git a/loc/sl_SI.json b/loc/sl_SI.json index 8709cdd7ee..4f9cf70487 100644 --- a/loc/sl_SI.json +++ b/loc/sl_SI.json @@ -305,7 +305,6 @@ "cpfp_title": "Povečaj omrežnino (CPFP)", "details_balance_hide": "Skrij Stanje", "details_balance_show": "Prikaži Stanje", - "details_block": "Višina Bloka", "details_copy": "Kopiraj", "details_copy_amount": "Kopiraj znesek", "details_copy_block_explorer_link": "Kopiraj povezavo razisk. blokov", @@ -316,7 +315,7 @@ "details_outputs": "Izhodi", "date": "Datum", "details_received": "Prejeto", - "transaction_note_saved": "Opomba transakcije je bila uspešno shranjena.", + "transaction_saved": "Shranjeno", "details_show_in_block_explorer": "Prikaži v raziskovalcu blokov", "details_title": "Transakcija", "details_to": "Izhod", @@ -403,9 +402,9 @@ "list_empty_txs2": "Začnite uporabljati denarnico.", "list_empty_txs2_lightning": "\nČe želite začeti z uporabo, tapnite na \"uredi sredstva\" in napolnite denarnico.", "list_latest_transaction": "Zadnja transakcija", - "list_ln_browser": "LApp Brskalnik", "list_long_choose": "Izberite fotografijo", "list_long_clipboard": "Kopiraj iz odložišča", + "import_file": "Uvozi datoteko", "list_long_scan": "Skeniraj QR kodo", "list_title": "Denarnice", "list_tryagain": "Poskusi ponovno", diff --git a/loc/sv_se.json b/loc/sv_se.json index ad3aee2836..1309458d88 100644 --- a/loc/sv_se.json +++ b/loc/sv_se.json @@ -317,7 +317,6 @@ "cpfp_title": "Höj avgift (CPFP)", "details_balance_hide": "Göm saldo", "details_balance_show": "Visa saldo", - "details_block": "Block höjd", "details_copy": "Kopiera", "details_copy_amount": "Kopiera belopp", "details_copy_block_explorer_link": "Kopiera Block Explorer Länk", @@ -328,7 +327,7 @@ "details_outputs": "Outputs", "date": "Datum", "details_received": "Mottaget", - "transaction_note_saved": "Transaktions anteckningen har sparats.", + "transaction_saved": "Sparad", "details_show_in_block_explorer": "Visa i block explorer", "details_title": "Transaktion", "details_to": "Output", @@ -417,9 +416,9 @@ "list_empty_txs2": "Börja med din plånbok.", "list_empty_txs2_lightning": "\nFör att komma igång klicka på \"sätt in / ta ut\" ovan och sätt in dina första bitcoin.", "list_latest_transaction": "Senaste transaktion", - "list_ln_browser": "LApp webbläsare", "list_long_choose": "Välj Foto", "list_long_clipboard": "Kopiera från Urklipp", + "import_file": "Importera fil", "list_long_scan": "Skanna QR kod", "list_title": "Plånböcker", "list_tryagain": "Försök igen", @@ -560,8 +559,6 @@ }, "bip47": { "payment_code": "Betalningskod", - "payment_codes_list": "Lista över betalningskoder", - "who_can_pay_me": "Vem kan betala mig:", "purpose": "Återanvändbar och delbar kod (BIP47)", "not_found": "Betalningskoden hittades inte" } diff --git a/loc/th_th.json b/loc/th_th.json index 4819db41f0..01bc10893d 100644 --- a/loc/th_th.json +++ b/loc/th_th.json @@ -207,12 +207,12 @@ "cpfp_title": "เพิ่มค่าธรรมเนียม (CPFP)", "details_balance_hide": "ซ่อนยอดคงเหลือ", "details_balance_show": "แสดงยอดคงเหลือ", - "details_block": "บล็อกไฮต์", "details_copy": "ก๊อปปี้", "details_from": "อินพุท", "details_inputs": "อินพุท", "details_outputs": "เอ้าพุท", "details_received": "ได้รับแล้ว", + "transaction_saved": "บันทึกแล้ว", "details_show_in_block_explorer": "แสดงด้วย block explorer", "details_title": "ธุรกรรม", "details_to": "เอ้าพุท", @@ -266,6 +266,7 @@ "list_latest_transaction": "ธุรกรรมล่าสุด", "list_long_choose": "เลือกรูปภาพ", "list_long_clipboard": "คัดลอกจากคลิปบอร์ด", + "import_file": "นำเข้าไฟล์", "list_long_scan": "สแกนคิวอาร์โค้ด", "list_title": "กระเป๋าสตางค์", "list_tryagain": "พยายามอีกครั้ง", diff --git a/loc/tr_tr.json b/loc/tr_tr.json index a0d7612c9d..157b689c26 100644 --- a/loc/tr_tr.json +++ b/loc/tr_tr.json @@ -187,6 +187,7 @@ "cpfp_create": "Oluştur", "details_copy": "Kopya", "details_from": "Girdi", + "transaction_saved": "Kaydedildi", "details_show_in_block_explorer": "Blok gezgininde göster", "details_title": "İşlem", "details_to": "Çıktı", diff --git a/loc/ua.json b/loc/ua.json index 205abd4df9..db15313b5d 100644 --- a/loc/ua.json +++ b/loc/ua.json @@ -242,6 +242,7 @@ "details_copy_amount": "Копіювати Суму", "details_copy_note": "Копіювати Нотатку", "details_from": "Від", + "transaction_saved": "Збережено", "details_show_in_block_explorer": "Show in block explorer", "details_title": "Деталі транзакції", "details_to": "Кому", @@ -294,6 +295,7 @@ "list_empty_txs2": "Почніть зі свого гаманця.", "list_latest_transaction": "Остання Транзакція", "list_long_choose": "Виберіть Фото", + "import_file": "Імпортувати Файл", "list_long_scan": "Сканувати QR-код", "list_title": "Гаманці", "list_tryagain": "Спробуйте ще раз", diff --git a/loc/vi_vn.json b/loc/vi_vn.json index c3f7d4b1c2..4bcf5be2f1 100644 --- a/loc/vi_vn.json +++ b/loc/vi_vn.json @@ -311,7 +311,6 @@ "cpfp_title": "Phí tăng (CPFP)", "details_balance_hide": "Giấu số dư", "details_balance_show": "Hiển thị số dư ", - "details_block": "Chiều cao khối", "details_copy": "Sao chép", "details_copy_amount": "Sao chép số tiền", "details_copy_block_explorer_link": "Sao chép liên kết Block Explorer", @@ -322,7 +321,7 @@ "details_outputs": "Các đầu ra", "date": "Ngày", "details_received": "Đã nhận", - "transaction_note_saved": "Ghi chú giao dịch đã được lưu thành công.", + "transaction_saved": "Đã lưu", "details_show_in_block_explorer": "Xem trong Block Explorer", "details_title": "Giao dịch", "details_to": "Đầu ra", @@ -411,7 +410,6 @@ "list_empty_txs2": "Bắt đầu với ví của bạn.", "list_empty_txs2_lightning": "\nĐể bắt đầu sử dụng nó, chạm vào Quản lý tiền, và nạp tiền vào số dư của bạn. ", "list_latest_transaction": "Giao dịch mới nhất", - "list_ln_browser": "Trình duyệt LApp", "list_long_choose": "Chọn hình", "list_long_clipboard": "Sao chép từ bảng tạm", "list_long_scan": "Quét mã QR", @@ -554,8 +552,6 @@ }, "bip47": { "payment_code": "Mã thanh toán", - "payment_codes_list": "Danh sách mã thanh toán", - "who_can_pay_me": "Ai có thể trả cho tôi:", "purpose": "Mã có thể sử dụng lại và có thể chia sẻ (BIP47)", "not_found": "Không tìm thấy mã thanh toán" } diff --git a/loc/zh_cn.json b/loc/zh_cn.json index ae391aed6f..f9ac27c731 100644 --- a/loc/zh_cn.json +++ b/loc/zh_cn.json @@ -254,7 +254,6 @@ "cpfp_title": "碰撞费用 (CPFP)", "details_balance_hide": "隐藏余额", "details_balance_show": "显示余额", - "details_block": "区块高", "details_copy": "复制", "details_copy_amount": "复制金额", "details_copy_txid": "复制 Tx ID", @@ -262,7 +261,7 @@ "details_inputs": "输入", "details_outputs": "输出", "details_received": "已收到", - "transaction_note_saved": "交易记录已成功保存。", + "transaction_saved": "已保存", "details_show_in_block_explorer": "在区块浏览器查看", "details_title": "转账", "details_to": "输出", @@ -331,9 +330,9 @@ "list_empty_txs2": "从你的钱包开始。", "list_empty_txs2_lightning": "\n要开始使用它,请点击“管理资金”并充值。", "list_latest_transaction": "最近的交易", - "list_ln_browser": "LApp浏览器", "list_long_choose": "选择图片", "list_long_clipboard": "从剪贴板复制", + "import_file": "导入文件", "list_long_scan": "扫描二维码", "list_title": "钱包", "list_tryagain": "再试一次", diff --git a/loc/zh_tw.json b/loc/zh_tw.json index 82a743edc0..db99375e56 100644 --- a/loc/zh_tw.json +++ b/loc/zh_tw.json @@ -248,14 +248,13 @@ "cpfp_title": "對碰費用 (CPFP)", "details_balance_hide": "隱藏結餘", "details_balance_show": "顯示結餘", - "details_block": "區塊高度", "details_copy": "複製", "details_copy_amount": "複製數量", "details_from": "輸入", "details_inputs": "輸入", "details_outputs": "輸出", "details_received": "已收到", - "transaction_note_saved": "交易記錄已成功儲存。", + "transaction_saved": "已儲存", "details_show_in_block_explorer": "區塊瀏覽器展示", "details_title": "轉賬", "details_to": "輸出", @@ -324,9 +323,9 @@ "list_empty_txs2": "從你的錢包開始。", "list_empty_txs2_lightning": "\n要開始使用它,請點擊“管理資金”並增值。", "list_latest_transaction": "最近的交易", - "list_ln_browser": "LApp瀏覽器", "list_long_choose": "選擇圖片", "list_long_clipboard": "從剪貼簿複製", + "import_file": "匯入檔案", "list_long_scan": "掃描二維碼", "list_title": "錢包", "list_tryagain": "再試一次", From 8d207e820d3c3920501484f136dd61d6cdaa3bac Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Sat, 1 Jun 2024 11:47:06 +0100 Subject: [PATCH 021/114] fix: upgrade slip39 dependency --- class/wallets/slip39-wallets.ts | 2 +- package-lock.json | 10 +++++----- package.json | 2 +- typings/slip39.d.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/class/wallets/slip39-wallets.ts b/class/wallets/slip39-wallets.ts index 1d5b55d35a..0ee4e098dc 100644 --- a/class/wallets/slip39-wallets.ts +++ b/class/wallets/slip39-wallets.ts @@ -1,6 +1,6 @@ import createHash from 'create-hash'; import slip39 from 'slip39'; -import { WORD_LIST } from 'slip39/dist/slip39_helper'; +import { WORD_LIST } from 'slip39/src/slip39_helper'; import { HDLegacyP2PKHWallet } from './hd-legacy-p2pkh-wallet'; import { HDSegwitBech32Wallet } from './hd-segwit-bech32-wallet'; diff --git a/package-lock.json b/package-lock.json index b4192f33a0..1b75020192 100644 --- a/package-lock.json +++ b/package-lock.json @@ -103,7 +103,7 @@ "rn-nodeify": "10.3.0", "scryptsy": "2.1.0", "silent-payments": "github:BlueWallet/SilentPayments#7ac4d17", - "slip39": "https://github.com/BlueWallet/slip39-js", + "slip39": "https://github.com/BlueWallet/slip39-js#d316ee6", "stream-browserify": "3.0.0", "url": "0.11.3", "wif": "2.0.6" @@ -21093,8 +21093,8 @@ } }, "node_modules/slip39": { - "version": "0.1.7", - "resolved": "git+ssh://git@github.com/BlueWallet/slip39-js.git#35619ed112fa022de1f5a3b6e2996dd3025472b2", + "version": "0.1.9", + "resolved": "git+ssh://git@github.com/BlueWallet/slip39-js.git#d316ee6a929ab645fe5462ef1c91720eb66889c8", "license": "MIT" }, "node_modules/source-map": { @@ -38395,8 +38395,8 @@ } }, "slip39": { - "version": "git+ssh://git@github.com/BlueWallet/slip39-js.git#35619ed112fa022de1f5a3b6e2996dd3025472b2", - "from": "slip39@https://github.com/BlueWallet/slip39-js" + "version": "git+ssh://git@github.com/BlueWallet/slip39-js.git#d316ee6a929ab645fe5462ef1c91720eb66889c8", + "from": "slip39@https://github.com/BlueWallet/slip39-js#d316ee6" }, "source-map": { "version": "0.6.1", diff --git a/package.json b/package.json index 7f9293004e..c8a69da297 100644 --- a/package.json +++ b/package.json @@ -188,7 +188,7 @@ "rn-nodeify": "10.3.0", "scryptsy": "2.1.0", "silent-payments": "github:BlueWallet/SilentPayments#7ac4d17", - "slip39": "https://github.com/BlueWallet/slip39-js", + "slip39": "https://github.com/BlueWallet/slip39-js#d316ee6", "stream-browserify": "3.0.0", "url": "0.11.3", "wif": "2.0.6" diff --git a/typings/slip39.d.ts b/typings/slip39.d.ts index bfd2628d02..82ba79e68c 100644 --- a/typings/slip39.d.ts +++ b/typings/slip39.d.ts @@ -3,6 +3,6 @@ declare module 'slip39' { export function validateMnemonic(mnemonic: string): boolean; } -declare module 'slip39/dist/slip39_helper' { +declare module 'slip39/src/slip39_helper' { export const WORD_LIST: string[]; } From cfc09154719fb595b06401f6d9a4baf90ec0a902 Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Sun, 2 Jun 2024 20:31:14 +0100 Subject: [PATCH 022/114] fix: SLIP39 1-of-1 --- class/wallet-import.ts | 55 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/class/wallet-import.ts b/class/wallet-import.ts index 6a60e95453..6fe56fc440 100644 --- a/class/wallet-import.ts +++ b/class/wallet-import.ts @@ -381,40 +381,37 @@ const startImport = ( yield { wallet: aezeed2 }; // not fetching txs or balances, fuck it, yolo, life is too short } - // if it is multi-line string, then it is probably SLIP39 wallet - // each line - one share + // Let's try SLIP39 yield { progress: 'SLIP39' }; - if (text.includes('\n')) { - const s1 = new SLIP39SegwitP2SHWallet(); - s1.setSecret(text); + const s1 = new SLIP39SegwitP2SHWallet(); + s1.setSecret(text); - if (s1.validateMnemonic()) { - yield { progress: 'SLIP39 p2wpkh-p2sh' }; - if (password) { - s1.setPassphrase(password); - } - if (await s1.wasEverUsed()) { - yield { wallet: s1 }; - } + if (s1.validateMnemonic()) { + yield { progress: 'SLIP39 p2wpkh-p2sh' }; + if (password) { + s1.setPassphrase(password); + } + if (await s1.wasEverUsed()) { + yield { wallet: s1 }; + } - yield { progress: 'SLIP39 p2pkh' }; - const s2 = new SLIP39LegacyP2PKHWallet(); - if (password) { - s2.setPassphrase(password); - } - s2.setSecret(text); - if (await s2.wasEverUsed()) { - yield { wallet: s2 }; - } + yield { progress: 'SLIP39 p2pkh' }; + const s2 = new SLIP39LegacyP2PKHWallet(); + if (password) { + s2.setPassphrase(password); + } + s2.setSecret(text); + if (await s2.wasEverUsed()) { + yield { wallet: s2 }; + } - yield { progress: 'SLIP39 p2wpkh' }; - const s3 = new SLIP39SegwitBech32Wallet(); - s3.setSecret(text); - if (password) { - s3.setPassphrase(password); - } - yield { wallet: s3 }; + yield { progress: 'SLIP39 p2wpkh' }; + const s3 = new SLIP39SegwitBech32Wallet(); + s3.setSecret(text); + if (password) { + s3.setPassphrase(password); } + yield { wallet: s3 }; } // is it BC-UR payload with multiple accounts? From 6199828e9dbbaf1a20ee4d4af2faa7da632fc1f9 Mon Sep 17 00:00:00 2001 From: overtorment Date: Sun, 2 Jun 2024 22:37:58 +0100 Subject: [PATCH 023/114] FIX: buggy BIP47 add to contacts --- screen/send/SendDetails.tsx | 23 ++++ screen/wallets/PaymentCodesList.tsx | 181 ++++++++++++++++------------ 2 files changed, 129 insertions(+), 75 deletions(-) diff --git a/screen/send/SendDetails.tsx b/screen/send/SendDetails.tsx index 2014c10c61..5f79b9407a 100644 --- a/screen/send/SendDetails.tsx +++ b/screen/send/SendDetails.tsx @@ -505,6 +505,29 @@ const SendDetails = () => { } } + // validating payment codes, if any + if (!error) { + if (transaction.address.startsWith('sp1')) { + if (!wallet.allowSilentPaymentSend()) { + console.log('validation error'); + error = loc.send.cant_send_to_silentpayment_adress; + } + } + + if (transaction.address.startsWith('PM')) { + if (!wallet.allowBIP47()) { + console.log('validation error'); + error = loc.send.cant_send_to_bip47; + } else if (!(wallet as unknown as AbstractHDElectrumWallet).getBIP47NotificationTransaction(transaction.address)) { + console.log('validation error'); + error = loc.send.cant_find_bip47_notification; + } else { + // BIP47 is allowed, notif tx is in place, lets sync joint addresses with the receiver + await (wallet as unknown as AbstractHDElectrumWallet).syncBip47ReceiversAddresses(transaction.address); + } + } + } + if (error) { scrollView.current?.scrollToIndex({ index }); setIsLoading(false); diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index 36f2d5d3db..6ef2f10201 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -118,18 +118,44 @@ export default function PaymentCodesList() { } if (String(id) === String(Actions.pay)) { - // @ts-ignore idk how to fix - navigation.navigate('SendDetailsRoot', { - screen: 'SendDetails', - params: { - memo: '', - address: pc, - walletID, - }, - }); + const cl = new ContactList(); + if (cl.isBip352PaymentCodeValid(pc)) { + // ok its a SilentPayments code, ok to just send + _navigateToSend(pc); + return; + } + + // check if notif tx is in place and has confirmations + const foundWallet = wallets.find(w => w.getID() === walletID) as unknown as HDSegwitBech32Wallet; + assert(foundWallet, 'Internal error: cant find walletID ' + walletID); + const notifTx = foundWallet.getBIP47NotificationTransaction(pc); + if (!notifTx) { + await _addContact(pc); + return; + } + + if (!notifTx.confirmations) { + // when we just sent the confirmation tx and it havent confirmed yet + presentAlert({ message: loc.bip47.notification_tx_unconfirmed }); + return; + } + + _navigateToSend(pc); } }; + const _navigateToSend = (pc: string) => { + // @ts-ignore idk how to fix + navigation.navigate('SendDetailsRoot', { + screen: 'SendDetails', + params: { + memo: '', + address: pc, + walletID, + }, + }); + }; + const renderItem = (pc: string) => { const color = createHash('sha256').update(pc).digest().toString('hex').substring(0, 6); @@ -165,84 +191,89 @@ export default function PaymentCodesList() { const onAddContactPress = async () => { try { - const foundWallet = wallets.find(w => w.getID() === walletID) as unknown as HDSegwitBech32Wallet; - assert(foundWallet); - const newPc = await prompt(loc.bip47.add_contact, loc.bip47.provide_payment_code, true, 'plain-text'); if (!newPc) return; - const cl = new ContactList(); - if (!cl.isPaymentCodeValid(newPc)) { - presentAlert({ message: loc.bip47.invalid_pc }); - return; - } + await _addContact(newPc); + } catch (error: any) { + presentAlert({ message: error.message }); + } finally { + setIsLoading(false); + } + }; - if (cl.isBip352PaymentCodeValid(newPc)) { - // ok its a SilentPayments code, notification tx is not needed, just add it to recipients: - foundWallet.addBIP47Receiver(newPc); - setReload(Math.random()); - return; - } + const _addContact = async (newPc: string) => { + const foundWallet = wallets.find(w => w.getID() === walletID) as unknown as HDSegwitBech32Wallet; + assert(foundWallet, 'Internal error: cant find walletID ' + walletID); - setIsLoading(true); + const cl = new ContactList(); - const notificationTx = foundWallet.getBIP47NotificationTransaction(newPc); + if (!cl.isPaymentCodeValid(newPc)) { + presentAlert({ message: loc.bip47.invalid_pc }); + return; + } - if (notificationTx && notificationTx.confirmations > 0) { - // we previously sent notification transaction to him, so just need to add him to internals - foundWallet.addBIP47Receiver(newPc); - await foundWallet.syncBip47ReceiversAddresses(newPc); // so we can unwrap and save all his possible addresses - // (for a case if already have txs with him, we will now be able to label them on tx list) - await saveToDisk(); - setReload(Math.random()); - return; - } + if (cl.isBip352PaymentCodeValid(newPc)) { + // ok its a SilentPayments code, notification tx is not needed, just add it to recipients: + foundWallet.addBIP47Receiver(newPc); + setReload(Math.random()); + return; + } - if (notificationTx && notificationTx.confirmations === 0) { - // for a rare case when we just sent the confirmation tx and it havent confirmed yet - presentAlert({ message: loc.bip47.notification_tx_unconfirmed }); - return; - } + setIsLoading(true); - // need to send notif tx: + const notificationTx = foundWallet.getBIP47NotificationTransaction(newPc); - setLoadingText('Fetching UTXO...'); - await foundWallet.fetchUtxo(); - setLoadingText('Fetching fees...'); - const fees = await BlueElectrum.estimateFees(); - setLoadingText('Fetching change address...'); - const changeAddress = await foundWallet.getChangeAddressAsync(); - setLoadingText('Crafting notification transaction...'); - const { tx, fee } = foundWallet.createBip47NotificationTransaction(foundWallet.getUtxo(), newPc, fees.fast, changeAddress); + if (notificationTx && notificationTx.confirmations > 0) { + // we previously sent notification transaction to him, so just need to add him to internals + foundWallet.addBIP47Receiver(newPc); + await foundWallet.syncBip47ReceiversAddresses(newPc); // so we can unwrap and save all his possible addresses + // (for a case if already have txs with him, we will now be able to label them on tx list) + await saveToDisk(); + setReload(Math.random()); + return; + } - if (!tx) { - presentAlert({ message: loc.bip47.failed_create_notif_tx }); - return; - } + if (notificationTx && notificationTx.confirmations === 0) { + // for a rare case when we just sent the confirmation tx and it havent confirmed yet + presentAlert({ message: loc.bip47.notification_tx_unconfirmed }); + return; + } - setLoadingText(''); - if ( - await confirm( - loc.bip47.onchain_tx_needed, - `${loc.send.create_fee}: ${formatBalance(fee, BitcoinUnit.BTC)} (${satoshiToLocalCurrency(fee)}). `, - ) - ) { - setLoadingText('Broadcasting...'); - try { - await foundWallet.broadcastTx(tx.toHex()); - foundWallet.addBIP47Receiver(newPc); - presentAlert({ message: loc.bip47.notif_tx_sent }); - txMetadata[tx.getId()] = { memo: loc.bip47.notif_tx }; - setReload(Math.random()); - await new Promise(resolve => setTimeout(resolve, 5000)); // tx propagate on backend so our fetch will actually get the new tx - } catch (_) {} - setLoadingText('Fetching transactions...'); - await foundWallet.fetchTransactions(); - } - } catch (error: any) { - presentAlert({ message: error.message }); - } finally { - setIsLoading(false); + // need to send notif tx: + + setLoadingText('Fetching UTXO...'); + await foundWallet.fetchUtxo(); + setLoadingText('Fetching fees...'); + const fees = await BlueElectrum.estimateFees(); + setLoadingText('Fetching change address...'); + const changeAddress = await foundWallet.getChangeAddressAsync(); + setLoadingText('Crafting notification transaction...'); + const { tx, fee } = foundWallet.createBip47NotificationTransaction(foundWallet.getUtxo(), newPc, fees.fast, changeAddress); + + if (!tx) { + presentAlert({ message: loc.bip47.failed_create_notif_tx }); + return; + } + + setLoadingText(''); + if ( + await confirm( + loc.bip47.onchain_tx_needed, + `${loc.send.create_fee}: ${formatBalance(fee, BitcoinUnit.BTC)} (${satoshiToLocalCurrency(fee)}). `, + ) + ) { + setLoadingText('Broadcasting...'); + try { + await foundWallet.broadcastTx(tx.toHex()); + foundWallet.addBIP47Receiver(newPc); + presentAlert({ message: loc.bip47.notif_tx_sent }); + txMetadata[tx.getId()] = { memo: loc.bip47.notif_tx }; + setReload(Math.random()); + await new Promise(resolve => setTimeout(resolve, 5000)); // tx propagate on backend so our fetch will actually get the new tx + } catch (_) {} + setLoadingText('Fetching transactions...'); + await foundWallet.fetchTransactions(); } }; From 7bc3d02a43f32cb79148c2f8c1464835999bd304 Mon Sep 17 00:00:00 2001 From: overtorment Date: Sun, 2 Jun 2024 23:01:32 +0100 Subject: [PATCH 024/114] FIX: buggy BIP47 add to contacts --- loc/en.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/loc/en.json b/loc/en.json index f10cbbc6d4..53c4dbfaae 100644 --- a/loc/en.json +++ b/loc/en.json @@ -213,6 +213,9 @@ "success_done": "Done", "txSaved": "The transaction file ({filePath}) has been saved in your Downloads folder.", "file_saved_at_path": "The file ({fileName}) has been saved in your Downloads folder.", + "cant_send_to_silentpayment_adress": "This wallet cannot send to SilentPayment addresses", + "cant_send_to_bip47": "This wallet cannot send to BIP47 payment codes", + "cant_find_bip47_notification": "Add this Payment Code to contacts first", "problem_with_psbt": "Problem with PSBT" }, "settings": { From 8abe464435dbfbca64eb2a375528017dbb1d9cc3 Mon Sep 17 00:00:00 2001 From: "transifex-integration[bot]" <43880903+transifex-integration[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 20:33:34 +0000 Subject: [PATCH 025/114] Translate loc/en.json in de_DE 100% reviewed source file: 'loc/en.json' on 'de_DE'. --- loc/de_de.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/loc/de_de.json b/loc/de_de.json index 7ee7126b7c..44b51ea922 100644 --- a/loc/de_de.json +++ b/loc/de_de.json @@ -213,6 +213,9 @@ "success_done": "Fertig", "txSaved": "Die Transaktionsdatei ({filePath}) wurde im Download-Ordner gespeichert.", "file_saved_at_path": "Die Datei ({fileName}) wurde im Download-Ordner gespeichert.", + "cant_send_to_silentpayment_adress": "Diese Wallet kann nicht an Stille Zahlung Adressen senden", + "cant_send_to_bip47": "Dieses Wallet kann nicht an BIP47 Zahlungscodes senden", + "cant_find_bip47_notification": "Diesen Zahlungscode zuerst zu den Kontakten hinzufügen ", "problem_with_psbt": "PSBT-Problem" }, "settings": { @@ -617,6 +620,7 @@ }, "bip47": { "payment_code": "Zahlungscode", + "my_payment_code": "Mein Zahlungscode", "contacts": "Kontakte", "purpose": "Wiederverwendbarer und teilbarer Code (BIP47)", "pay_this_contact": "An diesen Kontakt zahlen", @@ -631,7 +635,7 @@ "notification_tx_unconfirmed": "Benachrichtigungstransaktion noch unbestätigt. Bitte warten", "failed_create_notif_tx": "On-Chain Transaktion konnte nicht in erstellt werden", "onchain_tx_needed": "On-Chain Transaktion benötigt.", - "notif_tx_sent": "Benachrichtigungstransaktion ist gesendet. Auf Bestätigung warten.", + "notif_tx_sent" : "Benachrichtigungstransaktion ist gesendet. Auf Bestätigung warten.", "notif_tx": "Benachrichtigungstransaktion", "not_found": "Zahlungscode nicht gefunden" } From a50f4145e1d7d814d6ccb36302d9e338afe8a0eb Mon Sep 17 00:00:00 2001 From: overtorment Date: Mon, 3 Jun 2024 22:51:38 +0100 Subject: [PATCH 026/114] REF: better error handling on BIP47 notification tx --- class/wallets/abstract-hd-electrum-wallet.ts | 10 +++++----- screen/wallets/PaymentCodesList.tsx | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/class/wallets/abstract-hd-electrum-wallet.ts b/class/wallets/abstract-hd-electrum-wallet.ts index f430c7e7a0..bb731df05a 100644 --- a/class/wallets/abstract-hd-electrum-wallet.ts +++ b/class/wallets/abstract-hd-electrum-wallet.ts @@ -1634,8 +1634,8 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { createBip47NotificationTransaction(utxos: CreateTransactionUtxo[], receiverPaymentCode: string, feeRate: number, changeAddress: string) { const aliceBip47 = BIP47Factory(ecc).fromBip39Seed(this.getSecret(), undefined, this.getPassphrase()); const bobBip47 = BIP47Factory(ecc).fromPaymentCode(receiverPaymentCode); - assert(utxos[0]); - assert(utxos[0].wif); + assert(utxos[0], 'No UTXO'); + assert(utxos[0].wif, 'No UTXO WIF'); // constructing targets: notification address, _dummy_ payload (+potential change might be added later) @@ -1662,7 +1662,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { false, 0, ); - assert(inputsTemp?.[0]?.wif); + assert(inputsTemp?.[0]?.wif, 'inputsTemp?.[0]?.wif assert failed'); // utxo selected. lets create op_return payload using the correct (first!) utxo and correct targets with that payload @@ -1701,8 +1701,8 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { false, 0, ); - assert(inputs && inputs[0] && inputs[0].wif); - assert(inputs[0].txid === inputsTemp[0].txid); // making sure that no funky business happened under the hood (its supposed to stay the same) + assert(inputs && inputs[0] && inputs[0].wif, 'inputs && inputs[0] && inputs[0].wif assert failed'); + assert(inputs[0].txid === inputsTemp[0].txid, 'inputs[0].txid === inputsTemp[0].txid assert failed'); // making sure that no funky business happened under the hood (its supposed to stay the same) return { tx, inputs, outputs, fee, psbt }; } diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index 6ef2f10201..8700d63ab1 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -249,6 +249,11 @@ export default function PaymentCodesList() { setLoadingText('Fetching change address...'); const changeAddress = await foundWallet.getChangeAddressAsync(); setLoadingText('Crafting notification transaction...'); + if (foundWallet.getUtxo().length === 0) { + // no balance..? + presentAlert({ message: loc.send.details_total_exceeds_balance }); + return; + } const { tx, fee } = foundWallet.createBip47NotificationTransaction(foundWallet.getUtxo(), newPc, fees.fast, changeAddress); if (!tx) { From fc4dddd1dfa6ca929709bc7126b5a36b065047a3 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Mon, 3 Jun 2024 21:27:21 -0400 Subject: [PATCH 027/114] DEL: Remove package --- NavigationService.ts | 10 +- components/addresses/AddressItem.tsx | 4 +- hooks/useBiometrics.ts | 158 +++++++++---------- hooks/useExtendedNavigation.ts | 4 +- ios/Podfile.lock | 6 - loc/en.json | 2 +- package-lock.json | 12 -- package.json | 1 - screen/UnlockWith.tsx | 4 +- screen/lnd/ldkOpenChannel.tsx | 4 +- screen/send/Confirm.tsx | 5 +- screen/settings/EncryptStorage.tsx | 4 +- screen/wallets/ViewEditMultisigCosigners.tsx | 4 +- 13 files changed, 102 insertions(+), 116 deletions(-) diff --git a/NavigationService.ts b/NavigationService.ts index 9f4bc5cf85..838b6a0838 100644 --- a/NavigationService.ts +++ b/NavigationService.ts @@ -1,4 +1,4 @@ -import { createNavigationContainerRef, NavigationAction, ParamListBase } from '@react-navigation/native'; +import { createNavigationContainerRef, NavigationAction, ParamListBase, StackActions } from '@react-navigation/native'; export const navigationRef = createNavigationContainerRef(); @@ -18,7 +18,13 @@ export function reset() { if (navigationRef.isReady()) { navigationRef.current?.reset({ index: 0, - routes: [{ name: 'UnlockWithScreenRoot' }], + routes: [{ name: 'UnlockWithScreen' }], }); } } + +export function popToTop() { + if (navigationRef.isReady()) { + navigationRef.current?.dispatch(StackActions.popToTop()); + } +} diff --git a/components/addresses/AddressItem.tsx b/components/addresses/AddressItem.tsx index f8ba7e1f4b..19808c7b99 100644 --- a/components/addresses/AddressItem.tsx +++ b/components/addresses/AddressItem.tsx @@ -6,7 +6,7 @@ import { ListItem } from 'react-native-elements'; import Share from 'react-native-share'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import confirm from '../../helpers/confirm'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics'; import loc, { formatBalance } from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; import presentAlert from '../Alert'; @@ -32,7 +32,7 @@ type NavigationProps = NativeStackNavigationProp; const AddressItem = ({ item, balanceUnit, walletID, allowSignVerifyMessage }: AddressItemProps) => { const { wallets } = useStorage(); const { colors } = useTheme(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const hasTransactions = item.transactions > 0; diff --git a/hooks/useBiometrics.ts b/hooks/useBiometrics.ts index efa334c295..da563b9ecc 100644 --- a/hooks/useBiometrics.ts +++ b/hooks/useBiometrics.ts @@ -1,7 +1,6 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { Alert, Platform } from 'react-native'; import ReactNativeBiometrics, { BiometryTypes as RNBiometryTypes } from 'react-native-biometrics'; -import PasscodeAuth from 'react-native-passcode-auth'; import RNSecureKeyStore, { ACCESSIBLE } from 'react-native-secure-key-store'; import loc from '../loc'; import * as NavigationService from '../NavigationService'; @@ -17,18 +16,18 @@ const Biometrics = 'Biometrics'; const clearKeychain = async () => { try { - console.log('Wiping keychain'); - console.log('Wiping key: data'); + console.debug('Wiping keychain'); + console.debug('Wiping key: data'); await RNSecureKeyStore.set('data', JSON.stringify({ data: { wallets: [] } }), { accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY, }); - console.log('Wiped key: data'); - console.log('Wiping key: data_encrypted'); + console.debug('Wiped key: data'); + console.debug('Wiping key: data_encrypted'); await RNSecureKeyStore.set('data_encrypted', '', { accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY }); - console.log('Wiped key: data_encrypted'); - console.log('Wiping key: STORAGEKEY'); + console.debug('Wiped key: data_encrypted'); + console.debug('Wiping key: STORAGEKEY'); await RNSecureKeyStore.set(STORAGEKEY, '', { accessible: ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY }); - console.log('Wiped key: STORAGEKEY'); + console.debug('Wiped key: STORAGEKEY'); NavigationService.reset(); } catch (error: any) { console.warn(error); @@ -36,33 +35,34 @@ const clearKeychain = async () => { } }; -const requestDevicePasscode = async () => { - let isDevicePasscodeSupported: boolean | undefined = false; +const unlockWithBiometrics = async () => { try { - isDevicePasscodeSupported = await PasscodeAuth.isSupported(); - if (isDevicePasscodeSupported) { - const isAuthenticated = await PasscodeAuth.authenticate(); - if (isAuthenticated) { - Alert.alert( - loc.settings.encrypt_tstorage, - loc.settings.biom_remove_decrypt, - [ - { text: loc._.cancel, style: 'cancel' }, - { - text: loc._.ok, - style: 'destructive', - onPress: async () => await clearKeychain(), - }, - ], - { cancelable: false }, - ); - } + const { available } = await rnBiometrics.isSensorAvailable(); + if (!available) { + return false; } - } catch { - isDevicePasscodeSupported = undefined; - } - if (isDevicePasscodeSupported === false) { - presentAlert({ message: loc.settings.biom_no_passcode }); + + return new Promise(resolve => { + rnBiometrics + .simplePrompt({ promptMessage: loc.settings.biom_conf_identity }) + .then((result: { success: any }) => { + if (result.success) { + resolve(true); + } else { + console.debug('Biometrics authentication failed'); + resolve(false); + } + }) + .catch((error: Error) => { + console.debug('Biometrics authentication error'); + presentAlert({ message: error.message }); + resolve(false); + }); + }); + } catch (e: Error | any) { + console.debug('Biometrics authentication error', e); + presentAlert({ message: e.message }); + return false; } }; @@ -75,13 +75,35 @@ const showKeychainWipeAlert = () => { { text: loc._.cancel, onPress: () => { - console.log('Cancel Pressed'); + console.debug('Cancel Pressed'); }, style: 'cancel', }, { text: loc._.ok, - onPress: () => requestDevicePasscode(), + onPress: async () => { + const { available } = await rnBiometrics.isSensorAvailable(); + if (!available) { + presentAlert({ message: loc.settings.biom_no_passcode }); + return; + } + const isAuthenticated = await unlockWithBiometrics(); + if (isAuthenticated) { + Alert.alert( + loc.settings.encrypt_tstorage, + loc.settings.biom_remove_decrypt, + [ + { text: loc._.cancel, style: 'cancel' }, + { + text: loc._.ok, + style: 'destructive', + onPress: async () => await clearKeychain(), + }, + ], + { cancelable: false }, + ); + } + }, style: 'default', }, ], @@ -108,19 +130,20 @@ const useBiometrics = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const isDeviceBiometricCapable = async () => { + const isDeviceBiometricCapable = useCallback(async () => { try { const { available } = await rnBiometrics.isSensorAvailable(); return available; } catch (e) { - console.log('Biometrics isDeviceBiometricCapable failed'); - console.log(e); + console.debug('Biometrics isDeviceBiometricCapable failed'); + console.debug(e); setBiometricUseEnabled(false); } return false; - }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); - const type = async () => { + const type = useCallback(async () => { try { const { available, biometryType } = await rnBiometrics.isSensorAvailable(); if (!available) { @@ -129,55 +152,34 @@ const useBiometrics = () => { return biometryType; } catch (e) { - console.log('Biometrics biometricType failed'); - console.log(e); + console.debug('Biometrics biometricType failed'); + console.debug(e); return undefined; } - }; + }, []); - const isBiometricUseEnabled = async () => { + const isBiometricUseEnabled = useCallback(async () => { try { const enabledBiometrics = await getItem(STORAGEKEY); return !!enabledBiometrics; } catch (_) {} return false; - }; + }, [getItem]); - const isBiometricUseCapableAndEnabled = async () => { + const isBiometricUseCapableAndEnabled = useCallback(async () => { const isEnabled = await isBiometricUseEnabled(); const isCapable = await isDeviceBiometricCapable(); return isEnabled && isCapable; - }; - - const setBiometricUseEnabled = async (value: boolean) => { - await setItem(STORAGEKEY, value === true ? '1' : ''); - setBiometricEnabled(value); - }; + }, [isBiometricUseEnabled, isDeviceBiometricCapable]); - const unlockWithBiometrics = async () => { - const isCapable = await isDeviceBiometricCapable(); - if (isCapable) { - return new Promise(resolve => { - rnBiometrics - .simplePrompt({ promptMessage: loc.settings.biom_conf_identity }) - .then((result: { success: any }) => { - if (result.success) { - resolve(true); - } else { - console.log('Biometrics authentication failed'); - resolve(false); - } - }) - .catch((error: Error) => { - console.log('Biometrics authentication error'); - presentAlert({ message: error.message }); - resolve(false); - }); - }); - } - return false; - }; + const setBiometricUseEnabled = useCallback( + async (value: boolean) => { + await setItem(STORAGEKEY, value === true ? '1' : ''); + setBiometricEnabled(value); + }, + [setItem], + ); return { isDeviceBiometricCapable, @@ -185,11 +187,9 @@ const useBiometrics = () => { isBiometricUseEnabled, isBiometricUseCapableAndEnabled, setBiometricUseEnabled, - unlockWithBiometrics, clearKeychain, - requestDevicePasscode, biometricEnabled, }; }; -export { FaceID, TouchID, Biometrics, RNBiometryTypes as BiometricType, useBiometrics, showKeychainWipeAlert }; +export { FaceID, TouchID, Biometrics, RNBiometryTypes as BiometricType, useBiometrics, showKeychainWipeAlert, unlockWithBiometrics }; diff --git a/hooks/useExtendedNavigation.ts b/hooks/useExtendedNavigation.ts index 82216f055a..6eeed1562c 100644 --- a/hooks/useExtendedNavigation.ts +++ b/hooks/useExtendedNavigation.ts @@ -1,7 +1,7 @@ import { useNavigation, NavigationProp, ParamListBase } from '@react-navigation/native'; import { navigationRef } from '../NavigationService'; import { presentWalletExportReminder } from '../helpers/presentWalletExportReminder'; -import { useBiometrics } from './useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from './useBiometrics'; import { useStorage } from './context/useStorage'; // List of screens that require biometrics @@ -13,7 +13,7 @@ const requiresWalletExportIsSaved = ['ReceiveDetailsRoot', 'WalletAddresses']; export const useExtendedNavigation = >(): T => { const originalNavigation = useNavigation(); const { wallets, saveToDisk } = useStorage(); - const { isBiometricUseEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseEnabled } = useBiometrics(); const enhancedNavigate: NavigationProp['navigate'] = (screenOrOptions: any, params?: any) => { let screenName: string; diff --git a/ios/Podfile.lock b/ios/Podfile.lock index a856adca80..8f8cd2380d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -24,8 +24,6 @@ PODS: - lottie-react-native (6.7.2): - lottie-ios (= 4.4.1) - React-Core - - PasscodeAuth (1.0.0): - - React - RCT-Folly (2021.07.22.00): - boost - DoubleConversion @@ -530,7 +528,6 @@ DEPENDENCIES: - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) - libevent (~> 2.1.12) - lottie-react-native (from `../node_modules/lottie-react-native`) - - PasscodeAuth (from `../node_modules/react-native-passcode-auth`) - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) @@ -629,8 +626,6 @@ EXTERNAL SOURCES: :podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" lottie-react-native: :path: "../node_modules/lottie-react-native" - PasscodeAuth: - :path: "../node_modules/react-native-passcode-auth" RCT-Folly: :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" RCTRequired: @@ -784,7 +779,6 @@ SPEC CHECKSUMS: libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 lottie-ios: e047b1d2e6239b787cc5e9755b988869cf190494 lottie-react-native: 17547b2f3c7034e2ae8672833fdb63262164d18a - PasscodeAuth: 3e88093ff46c31a952d8b36c488240de980517be RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: 264adaca1d8b1a9c078761891898d4142df05313 RCTTypeSafety: 279a89da7058a69899778a127be73fab38b84499 diff --git a/loc/en.json b/loc/en.json index 53c4dbfaae..d04f3045ad 100644 --- a/loc/en.json +++ b/loc/en.json @@ -240,7 +240,7 @@ "biometrics_no_longer_available": "Your device settings have changed and no longer match the selected security settings in the app. Please re-enable biometrics or passcode, then restart the app to apply these changes.", "biom_10times": "You have attempted to enter your password 10 times. Would you like to reset your storage? This will remove all wallets and decrypt your storage.", "biom_conf_identity": "Please confirm your identity.", - "biom_no_passcode": "Your device does not have a passcode. In order to proceed, please configure a passcode in the Settings app.", + "biom_no_passcode": "Your device does not have a passcode or biometrics enabled. In order to proceed, please configure a passcode or biometric in the Settings app.", "biom_remove_decrypt": "All your wallets will be removed and your storage will be decrypted. Are you sure you want to proceed?", "currency": "Currency", "currency_source": "Price is obtained from", diff --git a/package-lock.json b/package-lock.json index b4192f33a0..c593024541 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,7 +79,6 @@ "react-native-localize": "3.1.0", "react-native-modal": "13.0.1", "react-native-obscure": "https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb", - "react-native-passcode-auth": "https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12", "react-native-permissions": "4.1.5", "react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783", "react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376", @@ -19775,12 +19774,6 @@ "react-native": "^0.60.5" } }, - "node_modules/react-native-passcode-auth": { - "version": "1.0.0", - "resolved": "git+ssh://git@github.com/BlueWallet/react-native-passcode-auth.git#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12", - "integrity": "sha512-8FL4NDMZZVrbHr1f4555dV+GY3PLpmSbJ1wIbdW1r6zSaFe59g9ns4sdLliisjO+RvyDJP7UDPDaeu+2iJ26Bg==", - "license": "ISC" - }, "node_modules/react-native-permissions": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-4.1.5.tgz", @@ -37528,11 +37521,6 @@ "integrity": "sha512-bmzbnlXII8hW7steqwouzQW9cJ+mdA8HJ8pWkb0KD60jC5dYgJ0e66wgUiSTDNFPrvlEKriE4eEanoJFj7Q9pg==", "from": "react-native-obscure@https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb" }, - "react-native-passcode-auth": { - "version": "git+ssh://git@github.com/BlueWallet/react-native-passcode-auth.git#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12", - "integrity": "sha512-8FL4NDMZZVrbHr1f4555dV+GY3PLpmSbJ1wIbdW1r6zSaFe59g9ns4sdLliisjO+RvyDJP7UDPDaeu+2iJ26Bg==", - "from": "react-native-passcode-auth@https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12" - }, "react-native-permissions": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-4.1.5.tgz", diff --git a/package.json b/package.json index 7f9293004e..660e015e66 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,6 @@ "react-native-localize": "3.1.0", "react-native-modal": "13.0.1", "react-native-obscure": "https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb", - "react-native-passcode-auth": "https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12", "react-native-permissions": "4.1.5", "react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783", "react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376", diff --git a/screen/UnlockWith.tsx b/screen/UnlockWith.tsx index d2b09085a5..7f23447c35 100644 --- a/screen/UnlockWith.tsx +++ b/screen/UnlockWith.tsx @@ -4,7 +4,7 @@ import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapt import { BlueTextCentered } from '../BlueComponents'; import Button from '../components/Button'; import SafeArea from '../components/SafeArea'; -import { BiometricType, useBiometrics } from '../hooks/useBiometrics'; +import { BiometricType, unlockWithBiometrics, useBiometrics } from '../hooks/useBiometrics'; import loc from '../loc'; import { useStorage } from '../hooks/context/useStorage'; @@ -53,7 +53,7 @@ const UnlockWith: React.FC = () => { const [state, dispatch] = useReducer(reducer, initialState); const isUnlockingWallets = useRef(false); const { setWalletsInitialized, isStorageEncrypted, startAndDecrypt } = useStorage(); - const { deviceBiometricType, unlockWithBiometrics, isBiometricUseCapableAndEnabled, isBiometricUseEnabled } = useBiometrics(); + const { deviceBiometricType, isBiometricUseCapableAndEnabled, isBiometricUseEnabled } = useBiometrics(); useEffect(() => { setWalletsInitialized(false); diff --git a/screen/lnd/ldkOpenChannel.tsx b/screen/lnd/ldkOpenChannel.tsx index 765bd999a4..2b8571eba6 100644 --- a/screen/lnd/ldkOpenChannel.tsx +++ b/screen/lnd/ldkOpenChannel.tsx @@ -14,7 +14,7 @@ import { ArrowPicker } from '../../components/ArrowPicker'; import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics'; import loc from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; import { useStorage } from '../../hooks/context/useStorage'; @@ -34,7 +34,7 @@ type LdkOpenChannelProps = RouteProp< const LdkOpenChannel = (props: any) => { const { wallets, fetchAndSaveWalletTransactions } = useStorage(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const { colors }: { colors: any } = useTheme(); const { navigate, setParams } = useNavigation(); const { diff --git a/screen/send/Confirm.tsx b/screen/send/Confirm.tsx index b9ef0f3b83..a0e910eb9b 100644 --- a/screen/send/Confirm.tsx +++ b/screen/send/Confirm.tsx @@ -16,7 +16,7 @@ import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/h import SafeArea from '../../components/SafeArea'; import { satoshiToBTC, satoshiToLocalCurrency } from '../../blue_modules/currency'; import * as BlueElectrum from '../../blue_modules/BlueElectrum'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics'; import { TWallet, CreateTransactionTarget } from '../../class/wallets/types'; import PayjoinTransaction from '../../class/payjoin-transaction'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; @@ -66,7 +66,7 @@ type ConfirmNavigationProp = NativeStackNavigationProp { const { wallets, fetchAndSaveWalletTransactions, counterpartyMetadata, isElectrumDisabled } = useStorage(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const navigation = useExtendedNavigation(); const route = useRoute(); // Get the route and its params const { recipients, targets, walletID, fee, memo, tx, satoshiPerByte, psbt, payjoinUrl } = route.params; // Destructure params @@ -148,7 +148,6 @@ const Confirm: React.FC = () => { satoshiPerByte, wallet, feeSatoshi, - unlockWithBiometrics, ], ); diff --git a/screen/settings/EncryptStorage.tsx b/screen/settings/EncryptStorage.tsx index a36a467400..52c1e90166 100644 --- a/screen/settings/EncryptStorage.tsx +++ b/screen/settings/EncryptStorage.tsx @@ -8,7 +8,7 @@ import presentAlert from '../../components/Alert'; import ListItem from '../../components/ListItem'; import { useTheme } from '../../components/themes'; import prompt from '../../helpers/prompt'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics'; import loc from '../../loc'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import { useStorage } from '../../hooks/context/useStorage'; @@ -56,7 +56,7 @@ const reducer = (state: State, action: Action): State => { const EncryptStorage = () => { const { isStorageEncrypted, encryptStorage, decryptStorage, saveToDisk } = useStorage(); - const { isDeviceBiometricCapable, biometricEnabled, setBiometricUseEnabled, deviceBiometricType, unlockWithBiometrics } = useBiometrics(); + const { isDeviceBiometricCapable, biometricEnabled, setBiometricUseEnabled, deviceBiometricType } = useBiometrics(); const [state, dispatch] = useReducer(reducer, initialState); const { navigate, dispatch: navigationDispatch } = useExtendedNavigation(); const { colors } = useTheme(); diff --git a/screen/wallets/ViewEditMultisigCosigners.tsx b/screen/wallets/ViewEditMultisigCosigners.tsx index 16402eaba2..b108c81445 100644 --- a/screen/wallets/ViewEditMultisigCosigners.tsx +++ b/screen/wallets/ViewEditMultisigCosigners.tsx @@ -44,7 +44,7 @@ import SquareEnumeratedWords, { SquareEnumeratedWordsContentAlign } from '../../ import { useTheme } from '../../components/themes'; import prompt from '../../helpers/prompt'; import { scanQrHelper } from '../../helpers/scan-qr'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; @@ -56,7 +56,7 @@ const ViewEditMultisigCosigners: React.FC = () => { const hasLoaded = useRef(false); const { colors } = useTheme(); const { wallets, setWalletsWithNewOrder, isElectrumDisabled } = useStorage(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const { isAdvancedModeEnabled } = useSettings(); const { navigate, dispatch, addListener } = useExtendedNavigation(); const openScannerButtonRef = useRef(); From 5730f467a602816d561018e7ad869aa931ea52e0 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Mon, 3 Jun 2024 21:54:32 -0400 Subject: [PATCH 028/114] FIX: import --- screen/lnd/lnurlPay.js | 4 ++-- screen/lnd/scanLndInvoice.js | 4 ++-- screen/send/psbtWithHardwareWallet.js | 4 ++-- screen/wallets/details.js | 4 ++-- screen/wallets/transactions.js | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/screen/lnd/lnurlPay.js b/screen/lnd/lnurlPay.js index 5f718b70fd..ee7854ec7b 100644 --- a/screen/lnd/lnurlPay.js +++ b/screen/lnd/lnurlPay.js @@ -13,7 +13,7 @@ import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import prompt from '../../helpers/prompt'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { useBiometrics, unlockWithBiometrics } from '../../hooks/useBiometrics'; import loc, { formatBalance, formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import { useStorage } from '../../hooks/context/useStorage'; @@ -28,7 +28,7 @@ const _cacheFiatToSat = {}; const LnurlPay = () => { const { wallets } = useStorage(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const { walletID, lnurl } = useRoute().params; /** @type {LightningCustodianWallet} */ const wallet = wallets.find(w => w.getID() === walletID); diff --git a/screen/lnd/scanLndInvoice.js b/screen/lnd/scanLndInvoice.js index edb69f6a9f..e110428066 100644 --- a/screen/lnd/scanLndInvoice.js +++ b/screen/lnd/scanLndInvoice.js @@ -23,14 +23,14 @@ import AmountInput from '../../components/AmountInput'; import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { useBiometrics, unlockWithBiometrics } from '../../hooks/useBiometrics'; import loc, { formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; import { useStorage } from '../../hooks/context/useStorage'; const ScanLndInvoice = () => { const { wallets, fetchAndSaveWalletTransactions } = useStorage(); - const { unlockWithBiometrics, isBiometricUseCapableAndEnabled } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const { colors } = useTheme(); const { walletID, uri, invoice } = useRoute().params; const name = useRoute().name; diff --git a/screen/send/psbtWithHardwareWallet.js b/screen/send/psbtWithHardwareWallet.js index a4df92baa6..35c6f8a630 100644 --- a/screen/send/psbtWithHardwareWallet.js +++ b/screen/send/psbtWithHardwareWallet.js @@ -16,14 +16,14 @@ import SaveFileButton from '../../components/SaveFileButton'; import { SecondButton } from '../../components/SecondButton'; import { useTheme } from '../../components/themes'; import { requestCameraAuthorization } from '../../helpers/scan-qr'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { useBiometrics, unlockWithBiometrics } from '../../hooks/useBiometrics'; import loc from '../../loc'; import { useStorage } from '../../hooks/context/useStorage'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; const PsbtWithHardwareWallet = () => { const { txMetadata, fetchAndSaveWalletTransactions, isElectrumDisabled } = useStorage(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const navigation = useExtendedNavigation(); const route = useRoute(); const { fromWallet, memo, psbt, deepLinkPSBT, launchedBy } = route.params; diff --git a/screen/wallets/details.js b/screen/wallets/details.js index 7643cdabc8..b46d387972 100644 --- a/screen/wallets/details.js +++ b/screen/wallets/details.js @@ -41,7 +41,7 @@ import SaveFileButton from '../../components/SaveFileButton'; import { SecondButton } from '../../components/SecondButton'; import { useTheme } from '../../components/themes'; import prompt from '../../helpers/prompt'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc, { formatBalanceWithoutSuffix } from '../../loc'; import { BitcoinUnit, Chain } from '../../models/bitcoinUnits'; @@ -108,7 +108,7 @@ const styles = StyleSheet.create({ const WalletDetails = () => { const { saveToDisk, wallets, deleteWallet, setSelectedWalletID, txMetadata } = useStorage(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const { walletID } = useRoute().params; const [isLoading, setIsLoading] = useState(false); const [backdoorPressed, setBackdoorPressed] = useState(0); diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index 4c0b2e6c32..31ec76a9b0 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -35,7 +35,7 @@ import { TransactionListItem } from '../../components/TransactionListItem'; import TransactionsNavigationHeader, { actionKeys } from '../../components/TransactionsNavigationHeader'; import { presentWalletExportReminder } from '../../helpers/presentWalletExportReminder'; import { scanQrHelper } from '../../helpers/scan-qr'; -import { useBiometrics } from '../../hooks/useBiometrics'; +import { unlockWithBiometrics, useBiometrics } from '../../hooks/useBiometrics'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import loc from '../../loc'; import { Chain } from '../../models/bitcoinUnits'; @@ -57,7 +57,7 @@ const WalletTransactions = ({ navigation }) => { isElectrumDisabled, setReloadTransactionsMenuActionFunction, } = useStorage(); - const { isBiometricUseCapableAndEnabled, unlockWithBiometrics } = useBiometrics(); + const { isBiometricUseCapableAndEnabled } = useBiometrics(); const [isLoading, setIsLoading] = useState(false); const { walletID } = useRoute().params; const { name } = useRoute(); From 246913418137695a7879ac1d24266a50e11eee4a Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Tue, 4 Jun 2024 00:23:53 -0400 Subject: [PATCH 029/114] FIX: If latest tx was unconfirmed, widget should show "Never" for latest --- components/WidgetCommunication.ios.tsx | 57 ++++++++++++++++---------- components/WidgetCommunication.tsx | 4 -- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/components/WidgetCommunication.ios.tsx b/components/WidgetCommunication.ios.tsx index 03f6fe6164..58f639722d 100644 --- a/components/WidgetCommunication.ios.tsx +++ b/components/WidgetCommunication.ios.tsx @@ -1,8 +1,9 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useCallback } from 'react'; import DefaultPreference from 'react-native-default-preference'; -import { TWallet } from '../class/wallets/types'; +import { TWallet, Transaction } from '../class/wallets/types'; import { useSettings } from '../hooks/context/useSettings'; import { useStorage } from '../hooks/context/useStorage'; +import { GROUP_IO_BLUEWALLET } from '../blue_modules/currency'; enum WidgetCommunicationKeys { AllWalletsSatoshiBalance = 'WidgetCommunicationAllWalletsSatoshiBalance', @@ -13,7 +14,7 @@ enum WidgetCommunicationKeys { export const isBalanceDisplayAllowed = async (): Promise => { try { - await DefaultPreference.setName('group.io.bluewallet.bluewallet'); + await DefaultPreference.setName(GROUP_IO_BLUEWALLET); const displayBalance = await DefaultPreference.get(WidgetCommunicationKeys.DisplayBalanceAllowed); return displayBalance === '1'; } catch { @@ -23,7 +24,7 @@ export const isBalanceDisplayAllowed = async (): Promise => { }; export const setBalanceDisplayAllowed = async (value: boolean): Promise => { - await DefaultPreference.setName('group.io.bluewallet.bluewallet'); + await DefaultPreference.setName(GROUP_IO_BLUEWALLET); if (value) { await DefaultPreference.set(WidgetCommunicationKeys.DisplayBalanceAllowed, '1'); } else { @@ -31,13 +32,6 @@ export const setBalanceDisplayAllowed = async (value: boolean): Promise => } }; -export const syncWidgetBalanceWithWallets = async (wallets: TWallet[], walletsInitialized: boolean): Promise => { - await DefaultPreference.setName('group.io.bluewallet.bluewallet'); - const { allWalletsBalance, latestTransactionTime } = await allWalletsBalanceAndTransactionTime(wallets, walletsInitialized); - await DefaultPreference.set(WidgetCommunicationKeys.AllWalletsSatoshiBalance, String(allWalletsBalance)); - await DefaultPreference.set(WidgetCommunicationKeys.AllWalletsLatestTransactionTime, String(latestTransactionTime)); -}; - const allWalletsBalanceAndTransactionTime = async ( wallets: TWallet[], walletsInitialized: boolean, @@ -47,15 +41,23 @@ const allWalletsBalanceAndTransactionTime = async ( } let balance = 0; let latestTransactionTime: number | string = 0; - wallets.forEach((wallet: TWallet) => { - if (wallet.hideBalance) return; - balance += wallet.getBalance(); - const walletLatestTime = wallet.getLatestTransactionTimeEpoch(); - if (typeof latestTransactionTime === 'number' && walletLatestTime > latestTransactionTime) { - latestTransactionTime = - wallet.getTransactions()[0]?.confirmations === 0 ? WidgetCommunicationKeys.LatestTransactionIsUnconfirmed : walletLatestTime; + + for (const wallet of wallets) { + if (wallet.hideBalance) continue; + balance += await wallet.getBalance(); + + const transactions: Transaction[] = await wallet.getTransactions(); + for (const transaction of transactions) { + const transactionTime = await wallet.getLatestTransactionTimeEpoch(); + if (transaction.confirmations > 0 && transactionTime > Number(latestTransactionTime)) { + latestTransactionTime = transactionTime; + } } - }); + + if (latestTransactionTime === 0 && transactions[0]?.confirmations === 0) { + latestTransactionTime = WidgetCommunicationKeys.LatestTransactionIsUnconfirmed; + } + } return { allWalletsBalance: balance, latestTransactionTime }; }; @@ -64,11 +66,24 @@ const WidgetCommunication: React.FC = () => { const { wallets, walletsInitialized } = useStorage(); const { isWidgetBalanceDisplayAllowed } = useSettings(); + const syncWidgetBalanceWithWallets = useCallback(async (): Promise => { + try { + await DefaultPreference.setName(GROUP_IO_BLUEWALLET); + const { allWalletsBalance, latestTransactionTime } = await allWalletsBalanceAndTransactionTime(wallets, walletsInitialized); + await Promise.all([ + DefaultPreference.set(WidgetCommunicationKeys.AllWalletsSatoshiBalance, String(allWalletsBalance)), + DefaultPreference.set(WidgetCommunicationKeys.AllWalletsLatestTransactionTime, String(latestTransactionTime)), + ]); + } catch (error) { + console.error('Failed to sync widget balance with wallets:', error); + } + }, [wallets, walletsInitialized]); + useEffect(() => { if (walletsInitialized) { - syncWidgetBalanceWithWallets(wallets, walletsInitialized); + syncWidgetBalanceWithWallets(); } - }, [wallets, walletsInitialized, isWidgetBalanceDisplayAllowed]); + }, [wallets, walletsInitialized, isWidgetBalanceDisplayAllowed, syncWidgetBalanceWithWallets]); return null; }; diff --git a/components/WidgetCommunication.tsx b/components/WidgetCommunication.tsx index b4cfacd1d9..4f516978ea 100644 --- a/components/WidgetCommunication.tsx +++ b/components/WidgetCommunication.tsx @@ -1,15 +1,11 @@ import React from 'react'; -import { TWallet } from '../class/wallets/types'; - export const isBalanceDisplayAllowed = async (): Promise => { return true; }; export const setBalanceDisplayAllowed = async (value: boolean): Promise => {}; -export const syncWidgetBalanceWithWallets = async (_wallets: TWallet[], _walletsInitialized: boolean): Promise => {}; - const WidgetCommunication: React.FC = () => { return null; // This component does not render anything. }; From 5f9183c5d5ac4013ace08288f0cf1484d6b8a7a7 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 1 Jun 2024 18:37:27 -0400 Subject: [PATCH 030/114] Update PaymentCodesList.tsx --- screen/wallets/PaymentCodesList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/screen/wallets/PaymentCodesList.tsx b/screen/wallets/PaymentCodesList.tsx index 8700d63ab1..531adc7a1b 100644 --- a/screen/wallets/PaymentCodesList.tsx +++ b/screen/wallets/PaymentCodesList.tsx @@ -49,7 +49,7 @@ const actionKeys: Action[] = [ text: loc.bip47.rename_contact, icon: { iconType: 'SYSTEM', - iconValue: 'note.text', + iconValue: 'pencil', }, }, { @@ -57,7 +57,7 @@ const actionKeys: Action[] = [ text: loc.bip47.copy_payment_code, icon: { iconType: 'SYSTEM', - iconValue: 'pencil', + iconValue: 'doc.on.doc', }, }, ]; From 1b2f2f00519b49a3e9c22a578dd391e2b571b337 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Tue, 4 Jun 2024 10:50:15 -0400 Subject: [PATCH 031/114] ADD: Handoff TXID to be able to quickly browse on other devicess --- navigation/SendDetailsStackParamList.ts | 1 + screen/send/Confirm.tsx | 1 + screen/send/success.js | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/navigation/SendDetailsStackParamList.ts b/navigation/SendDetailsStackParamList.ts index 3c55ac7886..d387b9f768 100644 --- a/navigation/SendDetailsStackParamList.ts +++ b/navigation/SendDetailsStackParamList.ts @@ -60,6 +60,7 @@ export type SendDetailsStackParamList = { Success: { fee: number; amount: number; + txid?: string; }; SelectWallet: { onWalletSelect: (wallet: TWallet) => void; diff --git a/screen/send/Confirm.tsx b/screen/send/Confirm.tsx index a0e910eb9b..0a80c82b20 100644 --- a/screen/send/Confirm.tsx +++ b/screen/send/Confirm.tsx @@ -211,6 +211,7 @@ const Confirm: React.FC = () => { navigate('Success', { fee: Number(fee), amount, + txid, }); dispatch({ type: ActionType.SET_LOADING, payload: false }); diff --git a/screen/send/success.js b/screen/send/success.js index 9c2e150adf..4840d9944f 100644 --- a/screen/send/success.js +++ b/screen/send/success.js @@ -12,6 +12,7 @@ import SafeArea from '../../components/SafeArea'; import { useTheme } from '../../components/themes'; import loc from '../../loc'; import { BitcoinUnit } from '../../models/bitcoinUnits'; +import HandOffComponent from '../../components/HandOffComponent'; const Success = () => { const pop = () => { @@ -19,7 +20,7 @@ const Success = () => { }; const { colors } = useTheme(); const { getParent } = useNavigation(); - const { amount, fee, amountUnit = BitcoinUnit.BTC, invoiceDescription = '', onDonePressed = pop } = useRoute().params; + const { amount, fee, amountUnit = BitcoinUnit.BTC, invoiceDescription = '', onDonePressed = pop, txid } = useRoute().params; const stylesHook = StyleSheet.create({ root: { backgroundColor: colors.elevated, @@ -47,6 +48,13 @@ const Success = () => {