2018-10-30 10:35:24 +01:00
|
|
|
/* global alert */
|
2021-09-23 15:05:10 +02:00
|
|
|
import React, { useEffect, useState, useCallback, useContext, useRef, useMemo } from 'react';
|
2019-09-27 16:49:56 +02:00
|
|
|
import {
|
|
|
|
View,
|
|
|
|
Text,
|
|
|
|
TextInput,
|
|
|
|
Alert,
|
2020-01-02 23:06:51 +01:00
|
|
|
KeyboardAvoidingView,
|
2019-09-27 16:49:56 +02:00
|
|
|
TouchableOpacity,
|
|
|
|
Keyboard,
|
|
|
|
TouchableWithoutFeedback,
|
|
|
|
Switch,
|
2020-04-16 13:41:12 +02:00
|
|
|
Platform,
|
|
|
|
Linking,
|
2020-05-24 11:17:26 +02:00
|
|
|
StyleSheet,
|
2020-06-11 05:54:47 +02:00
|
|
|
StatusBar,
|
2021-08-03 03:27:54 +02:00
|
|
|
ScrollView,
|
2020-09-20 10:51:58 +02:00
|
|
|
PermissionsAndroid,
|
2021-05-04 05:25:18 +02:00
|
|
|
InteractionManager,
|
|
|
|
ActivityIndicator,
|
2021-05-22 05:36:34 +02:00
|
|
|
I18nManager,
|
2019-09-27 16:49:56 +02:00
|
|
|
} from 'react-native';
|
2021-05-04 05:25:18 +02:00
|
|
|
import { BlueCard, BlueLoading, BlueSpacing10, BlueSpacing20, BlueText, SecondButton, BlueListItem } from '../../BlueComponents';
|
2020-12-25 17:09:53 +01:00
|
|
|
import navigationStyle from '../../components/navigationStyle';
|
2020-05-24 12:27:08 +02:00
|
|
|
import { LightningCustodianWallet } from '../../class/wallets/lightning-custodian-wallet';
|
2018-12-13 17:50:18 +01:00
|
|
|
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
2019-09-25 05:42:21 +02:00
|
|
|
import Biometric from '../../class/biometrics';
|
2021-01-28 13:54:23 +01:00
|
|
|
import {
|
|
|
|
HDSegwitBech32Wallet,
|
|
|
|
SegwitP2SHWallet,
|
|
|
|
LegacyWallet,
|
|
|
|
SegwitBech32Wallet,
|
|
|
|
WatchOnlyWallet,
|
|
|
|
MultisigHDWallet,
|
|
|
|
HDAezeedWallet,
|
2021-09-09 13:00:11 +02:00
|
|
|
LightningLdkWallet,
|
2021-01-28 13:54:23 +01:00
|
|
|
} from '../../class';
|
2020-07-20 15:38:46 +02:00
|
|
|
import loc from '../../loc';
|
2020-08-09 03:04:11 +02:00
|
|
|
import { useTheme, useRoute, useNavigation } from '@react-navigation/native';
|
2020-09-20 10:51:58 +02:00
|
|
|
import RNFS from 'react-native-fs';
|
|
|
|
import Share from 'react-native-share';
|
2020-10-24 19:20:59 +02:00
|
|
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
|
|
|
import Notifications from '../../blue_modules/notifications';
|
2021-05-29 07:57:40 +02:00
|
|
|
import { isDesktop } from '../../blue_modules/environment';
|
2021-02-04 08:05:37 +01:00
|
|
|
import { AbstractHDElectrumWallet } from '../../class/wallets/abstract-hd-electrum-wallet';
|
2021-08-19 15:29:52 +02:00
|
|
|
import { Chain } from '../../models/bitcoinUnits';
|
2021-05-04 05:25:18 +02:00
|
|
|
|
2020-07-01 13:56:52 +02:00
|
|
|
const prompt = require('../../blue_modules/prompt');
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-05-24 11:17:26 +02:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
root: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
scrollViewContent: {
|
|
|
|
flexGrow: 1,
|
|
|
|
},
|
|
|
|
save: {
|
|
|
|
marginHorizontal: 16,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
address: {
|
|
|
|
alignItems: 'center',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
textLabel1: {
|
|
|
|
fontWeight: '500',
|
|
|
|
fontSize: 14,
|
|
|
|
marginVertical: 12,
|
2021-05-22 05:36:34 +02:00
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
2020-05-24 11:17:26 +02:00
|
|
|
},
|
|
|
|
textLabel2: {
|
|
|
|
fontWeight: '500',
|
|
|
|
fontSize: 14,
|
|
|
|
marginVertical: 16,
|
2021-05-22 05:36:34 +02:00
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
2020-05-24 11:17:26 +02:00
|
|
|
},
|
|
|
|
textValue: {
|
|
|
|
fontWeight: '500',
|
|
|
|
fontSize: 14,
|
|
|
|
},
|
|
|
|
input: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
borderWidth: 1,
|
|
|
|
borderBottomWidth: 0.5,
|
|
|
|
minHeight: 44,
|
|
|
|
height: 44,
|
|
|
|
alignItems: 'center',
|
|
|
|
borderRadius: 4,
|
|
|
|
},
|
|
|
|
inputText: {
|
|
|
|
flex: 1,
|
|
|
|
marginHorizontal: 8,
|
|
|
|
minHeight: 33,
|
2020-06-09 14:23:21 +02:00
|
|
|
color: '#81868e',
|
2021-05-22 05:36:34 +02:00
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
2020-05-24 11:17:26 +02:00
|
|
|
},
|
|
|
|
hardware: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
},
|
|
|
|
delete: {
|
|
|
|
color: '#d0021b',
|
|
|
|
fontSize: 15,
|
|
|
|
fontWeight: '500',
|
2020-10-29 10:26:39 +01:00
|
|
|
textAlign: 'center',
|
2020-05-24 11:17:26 +02:00
|
|
|
},
|
2021-04-21 14:15:34 +02:00
|
|
|
row: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
},
|
2021-05-04 05:25:18 +02:00
|
|
|
marginRight16: {
|
|
|
|
marginRight: 16,
|
|
|
|
},
|
2020-05-24 11:17:26 +02:00
|
|
|
});
|
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
const WalletDetails = () => {
|
2020-11-15 19:19:55 +01:00
|
|
|
const { saveToDisk, wallets, deleteWallet, setSelectedWallet } = useContext(BlueStorageContext);
|
2020-10-24 19:20:59 +02:00
|
|
|
const { walletID } = useRoute().params;
|
2021-05-04 05:25:18 +02:00
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
2020-09-20 10:51:58 +02:00
|
|
|
const [backdoorPressed, setBackdoorPressed] = useState(0);
|
2020-10-24 19:20:59 +02:00
|
|
|
const wallet = useRef(wallets.find(w => w.getID() === walletID)).current;
|
2020-08-09 03:04:11 +02:00
|
|
|
const [walletName, setWalletName] = useState(wallet.getLabel());
|
|
|
|
const [useWithHardwareWallet, setUseWithHardwareWallet] = useState(wallet.useWithHardwareWalletEnabled());
|
2021-04-21 14:15:34 +02:00
|
|
|
const { isAdancedModeEnabled } = useContext(BlueStorageContext);
|
|
|
|
const [isAdvancedModeEnabledRender, setIsAdvancedModeEnabledRender] = useState(false);
|
2020-08-09 03:04:11 +02:00
|
|
|
const [hideTransactionsInWalletsList, setHideTransactionsInWalletsList] = useState(!wallet.getHideTransactionsInWalletsList());
|
2020-10-24 19:20:59 +02:00
|
|
|
const { goBack, navigate, setOptions, popToTop } = useNavigation();
|
2020-08-09 03:04:11 +02:00
|
|
|
const { colors } = useTheme();
|
2021-05-04 05:25:18 +02:00
|
|
|
const [masterFingerprint, setMasterFingerprint] = useState();
|
2021-09-23 15:05:10 +02:00
|
|
|
const derivationPath = useMemo(() => {
|
|
|
|
try {
|
|
|
|
return wallet.getDerivationPath();
|
|
|
|
} catch (e) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}, [wallet]);
|
2021-09-09 13:00:11 +02:00
|
|
|
const [lightningWalletInfo, setLightningWalletInfo] = useState({});
|
|
|
|
|
2021-05-04 05:25:18 +02:00
|
|
|
useEffect(() => {
|
|
|
|
if (isAdvancedModeEnabledRender && wallet.allowMasterFingerprint()) {
|
|
|
|
InteractionManager.runAfterInteractions(() => {
|
|
|
|
setMasterFingerprint(wallet.getMasterFingerprintHex());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, [isAdvancedModeEnabledRender, wallet]);
|
2020-08-09 03:04:11 +02:00
|
|
|
const stylesHook = StyleSheet.create({
|
|
|
|
textLabel1: {
|
|
|
|
color: colors.feeText,
|
|
|
|
},
|
|
|
|
textLabel2: {
|
|
|
|
color: colors.feeText,
|
|
|
|
},
|
|
|
|
saveText: {
|
|
|
|
color: colors.outputValue,
|
|
|
|
},
|
|
|
|
textValue: {
|
|
|
|
color: colors.outputValue,
|
|
|
|
},
|
|
|
|
input: {
|
|
|
|
borderColor: colors.formBorder,
|
|
|
|
borderBottomColor: colors.formBorder,
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
backgroundColor: colors.inputBackgroundColor,
|
|
|
|
},
|
|
|
|
});
|
2021-09-09 13:00:11 +02:00
|
|
|
useEffect(() => {
|
|
|
|
if (wallet.type === LightningLdkWallet.type) {
|
|
|
|
wallet.getInfo().then(setLightningWalletInfo);
|
|
|
|
}
|
|
|
|
}, [wallet]);
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2021-04-18 01:31:24 +02:00
|
|
|
const setLabel = () => {
|
|
|
|
setIsLoading(true);
|
2020-08-09 03:04:11 +02:00
|
|
|
if (walletName.trim().length > 0) {
|
2021-03-02 14:38:02 +01:00
|
|
|
wallet.setLabel(walletName.trim());
|
2021-04-19 20:05:55 +02:00
|
|
|
if (wallet.type === WatchOnlyWallet.type && wallet.isHd()) {
|
2020-08-09 03:04:11 +02:00
|
|
|
wallet.setUseWithHardwareWalletEnabled(useWithHardwareWallet);
|
2020-01-19 21:17:06 +01:00
|
|
|
}
|
2020-08-09 03:04:11 +02:00
|
|
|
wallet.setHideTransactionsInWalletsList(!hideTransactionsInWalletsList);
|
|
|
|
}
|
2021-04-18 01:31:24 +02:00
|
|
|
saveToDisk()
|
|
|
|
.then(() => {
|
|
|
|
alert(loc.wallets.details_wallet_updated);
|
|
|
|
goBack();
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log(error.message);
|
|
|
|
setIsLoading(false);
|
|
|
|
});
|
2020-10-24 19:20:59 +02:00
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
useEffect(() => {
|
2021-04-21 14:15:34 +02:00
|
|
|
isAdancedModeEnabled().then(setIsAdvancedModeEnabledRender);
|
2020-08-09 03:04:11 +02:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2020-10-24 19:20:59 +02:00
|
|
|
setOptions({
|
|
|
|
headerRight: () => (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" testID="Save" disabled={isLoading} style={styles.save} onPress={setLabel}>
|
2020-10-24 19:20:59 +02:00
|
|
|
<Text style={stylesHook.saveText}>{loc.wallets.details_save}</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
),
|
|
|
|
});
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [isLoading, colors.outputValue, walletName, useWithHardwareWallet, hideTransactionsInWalletsList]);
|
2020-08-09 03:04:11 +02:00
|
|
|
|
2020-11-15 19:19:55 +01:00
|
|
|
useEffect(() => {
|
2021-02-27 01:23:59 +01:00
|
|
|
if (wallets.some(wallet => wallet.getID() === walletID)) {
|
|
|
|
setSelectedWallet(walletID);
|
|
|
|
}
|
2020-11-15 19:19:55 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [walletID]);
|
|
|
|
|
2021-02-25 01:52:55 +01:00
|
|
|
const navigateToOverviewAndDeleteWallet = () => {
|
|
|
|
setIsLoading(true);
|
|
|
|
Notifications.unsubscribe(wallet.getAllExternalAddresses(), [], []);
|
|
|
|
popToTop();
|
|
|
|
deleteWallet(wallet);
|
2021-09-07 21:30:07 +02:00
|
|
|
saveToDisk(true);
|
2021-02-25 01:52:55 +01:00
|
|
|
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
|
|
|
|
};
|
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
const presentWalletHasBalanceAlert = useCallback(async () => {
|
2019-08-30 06:45:08 +02:00
|
|
|
ReactNativeHapticFeedback.trigger('notificationWarning', { ignoreAndroidSystemSettings: false });
|
2020-10-08 13:16:25 +02:00
|
|
|
try {
|
|
|
|
const walletBalanceConfirmation = await prompt(
|
|
|
|
loc.wallets.details_del_wb,
|
|
|
|
loc.formatString(loc.wallets.details_del_wb_q, { balance: wallet.getBalance() }),
|
|
|
|
true,
|
|
|
|
'plain-text',
|
2021-02-25 03:21:25 +01:00
|
|
|
true,
|
2020-10-08 13:16:25 +02:00
|
|
|
);
|
|
|
|
if (Number(walletBalanceConfirmation) === wallet.getBalance()) {
|
2021-02-25 01:52:55 +01:00
|
|
|
navigateToOverviewAndDeleteWallet();
|
2020-10-08 13:16:25 +02:00
|
|
|
} else {
|
|
|
|
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
|
|
|
|
setIsLoading(false);
|
|
|
|
alert(loc.wallets.details_del_wb_err);
|
|
|
|
}
|
|
|
|
} catch (_) {}
|
2020-10-24 19:20:59 +02:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2021-02-25 01:52:55 +01:00
|
|
|
}, []);
|
2019-08-30 06:45:08 +02:00
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
const navigateToWalletExport = () => {
|
2020-11-24 04:15:33 +01:00
|
|
|
navigate('WalletExportRoot', {
|
|
|
|
screen: 'WalletExport',
|
|
|
|
params: {
|
|
|
|
walletID: wallet.getID(),
|
|
|
|
},
|
2020-06-18 16:59:44 +02:00
|
|
|
});
|
|
|
|
};
|
2020-10-05 23:25:14 +02:00
|
|
|
const navigateToMultisigCoordinationSetup = () => {
|
2020-12-12 07:42:23 +01:00
|
|
|
navigate('ExportMultisigCoordinationSetupRoot', {
|
|
|
|
screen: 'ExportMultisigCoordinationSetup',
|
|
|
|
params: {
|
|
|
|
walletId: wallet.getID(),
|
|
|
|
},
|
2020-10-05 23:25:14 +02:00
|
|
|
});
|
|
|
|
};
|
2020-10-29 22:13:54 +01:00
|
|
|
const navigateToViewEditCosigners = () => {
|
2020-12-12 01:27:43 +01:00
|
|
|
navigate('ViewEditMultisigCosignersRoot', {
|
|
|
|
screen: 'ViewEditMultisigCosigners',
|
|
|
|
params: {
|
|
|
|
walletId: wallet.getID(),
|
|
|
|
},
|
2020-10-29 22:13:54 +01:00
|
|
|
});
|
|
|
|
};
|
2020-08-09 03:04:11 +02:00
|
|
|
const navigateToXPub = () =>
|
2020-11-24 04:15:33 +01:00
|
|
|
navigate('WalletXpubRoot', {
|
|
|
|
screen: 'WalletXpub',
|
|
|
|
params: {
|
2021-06-17 23:24:00 +02:00
|
|
|
walletID,
|
2020-11-24 04:15:33 +01:00
|
|
|
},
|
2020-08-09 03:04:11 +02:00
|
|
|
});
|
2021-03-23 13:16:32 +01:00
|
|
|
const navigateToSignVerify = () =>
|
|
|
|
navigate('SignVerifyRoot', {
|
|
|
|
screen: 'SignVerify',
|
|
|
|
params: {
|
|
|
|
walletID: wallet.getID(),
|
|
|
|
address: wallet.getAllExternalAddresses()[0], // works for both single address and HD wallets
|
|
|
|
},
|
|
|
|
});
|
2021-09-09 13:00:11 +02:00
|
|
|
const navigateToLdkViewLogs = () => {
|
|
|
|
navigate('LdkViewLogs', {
|
|
|
|
walletID,
|
|
|
|
});
|
|
|
|
};
|
2020-06-18 16:59:44 +02:00
|
|
|
|
2021-02-04 08:05:37 +01:00
|
|
|
const navigateToAddresses = () =>
|
2021-04-16 16:05:25 +02:00
|
|
|
navigate('WalletAddresses', {
|
2021-04-16 16:24:48 +02:00
|
|
|
walletID: wallet.getID(),
|
2021-02-04 08:05:37 +01:00
|
|
|
});
|
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
const renderMarketplaceButton = () => {
|
2021-08-19 15:29:52 +02:00
|
|
|
return (
|
|
|
|
wallet.chain === Chain.OFFCHAIN &&
|
|
|
|
Platform.select({
|
|
|
|
android: (
|
|
|
|
<>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton
|
|
|
|
testID="Marketplace"
|
|
|
|
onPress={() =>
|
|
|
|
navigate('Marketplace', {
|
|
|
|
walletID,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
title={loc.wallets.details_marketplace}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
ios: (
|
|
|
|
<>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton
|
|
|
|
testID="Marketplace"
|
|
|
|
onPress={async () => {
|
|
|
|
Linking.openURL('https://bluewallet.io/marketplace-btc/');
|
|
|
|
}}
|
|
|
|
title={loc.wallets.details_marketplace}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
})
|
|
|
|
);
|
2020-04-16 13:41:12 +02:00
|
|
|
};
|
|
|
|
|
2020-09-20 10:51:58 +02:00
|
|
|
const exportInternals = async () => {
|
|
|
|
if (backdoorPressed < 10) return setBackdoorPressed(backdoorPressed + 1);
|
|
|
|
setBackdoorPressed(0);
|
|
|
|
if (wallet.type !== HDSegwitBech32Wallet.type) return;
|
|
|
|
const fileName = 'wallet-externals.json';
|
|
|
|
const contents = JSON.stringify(
|
|
|
|
{
|
|
|
|
_balances_by_external_index: wallet._balances_by_external_index,
|
|
|
|
_balances_by_internal_index: wallet._balances_by_internal_index,
|
|
|
|
_txs_by_external_index: wallet._txs_by_external_index,
|
|
|
|
_txs_by_internal_index: wallet._txs_by_internal_index,
|
|
|
|
_utxo: wallet._utxo,
|
|
|
|
next_free_address_index: wallet.next_free_address_index,
|
|
|
|
next_free_change_address_index: wallet.next_free_change_address_index,
|
|
|
|
internal_addresses_cache: wallet.internal_addresses_cache,
|
|
|
|
external_addresses_cache: wallet.external_addresses_cache,
|
|
|
|
_xpub: wallet._xpub,
|
|
|
|
gap_limit: wallet.gap_limit,
|
|
|
|
label: wallet.label,
|
|
|
|
_lastTxFetch: wallet._lastTxFetch,
|
|
|
|
_lastBalanceFetch: wallet._lastBalanceFetch,
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
2,
|
|
|
|
);
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
const filePath = RNFS.TemporaryDirectoryPath + `/${fileName}`;
|
|
|
|
await RNFS.writeFile(filePath, contents);
|
|
|
|
Share.open({
|
|
|
|
url: 'file://' + filePath,
|
2021-05-29 07:57:40 +02:00
|
|
|
saveToFiles: isDesktop,
|
2020-09-20 10:51:58 +02:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log(error);
|
|
|
|
alert(error.message);
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
RNFS.unlink(filePath);
|
|
|
|
});
|
|
|
|
} else if (Platform.OS === 'android') {
|
|
|
|
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, {
|
|
|
|
title: loc.send.permission_storage_title,
|
|
|
|
message: loc.send.permission_storage_message,
|
|
|
|
buttonNeutral: loc.send.permission_storage_later,
|
|
|
|
buttonNegative: loc._.cancel,
|
|
|
|
buttonPositive: loc._.ok,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
|
|
|
|
console.log('Storage Permission: Granted');
|
|
|
|
const filePath = RNFS.DownloadDirectoryPath + `/${fileName}`;
|
2020-12-09 22:51:09 +01:00
|
|
|
try {
|
|
|
|
await RNFS.writeFile(filePath, contents);
|
|
|
|
alert(loc.formatString(loc.send.txSaved, { filePath: fileName }));
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
alert(e.message);
|
|
|
|
}
|
2020-09-20 10:51:58 +02:00
|
|
|
} else {
|
|
|
|
console.log('Storage Permission: Denied');
|
2020-11-23 14:55:32 +01:00
|
|
|
Alert.alert(loc.send.permission_storage_title, loc.send.permission_storage_denied_message, [
|
|
|
|
{
|
|
|
|
text: loc.send.open_settings,
|
|
|
|
onPress: () => {
|
|
|
|
Linking.openSettings();
|
|
|
|
},
|
|
|
|
style: 'default',
|
|
|
|
},
|
|
|
|
{ text: loc._.cancel, onPress: () => {}, style: 'cancel' },
|
|
|
|
]);
|
2020-09-20 10:51:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-27 17:35:14 +01:00
|
|
|
const purgeTransactions = async () => {
|
|
|
|
if (backdoorPressed < 10) return setBackdoorPressed(backdoorPressed + 1);
|
|
|
|
setBackdoorPressed(0);
|
|
|
|
const msg = 'Transactions purged. Pls go to main screen and back to rerender screen';
|
|
|
|
|
|
|
|
if (wallet.type === HDSegwitBech32Wallet.type) {
|
|
|
|
wallet._txs_by_external_index = {};
|
|
|
|
wallet._txs_by_internal_index = {};
|
|
|
|
alert(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wallet._hdWalletInstance) {
|
|
|
|
wallet._hdWalletInstance._txs_by_external_index = {};
|
|
|
|
wallet._hdWalletInstance._txs_by_internal_index = {};
|
|
|
|
alert(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
const walletNameTextInputOnBlur = () => {
|
|
|
|
if (walletName.trim().length === 0) {
|
|
|
|
const walletLabel = wallet.getLabel();
|
|
|
|
setWalletName(walletLabel);
|
2018-01-30 23:42:38 +01:00
|
|
|
}
|
2020-08-09 03:04:11 +02:00
|
|
|
};
|
2020-07-20 15:38:46 +02:00
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
const handleDeleteButtonTapped = () => {
|
|
|
|
ReactNativeHapticFeedback.trigger('notificationWarning', { ignoreAndroidSystemSettings: false });
|
|
|
|
Alert.alert(
|
|
|
|
loc.wallets.details_delete_wallet,
|
|
|
|
loc.wallets.details_are_you_sure,
|
|
|
|
[
|
|
|
|
{
|
|
|
|
text: loc.wallets.details_yes_delete,
|
|
|
|
onPress: async () => {
|
|
|
|
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
|
|
|
|
|
|
|
|
if (isBiometricsEnabled) {
|
|
|
|
if (!(await Biometric.unlockWithBiometrics())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (wallet.getBalance() > 0 && wallet.allowSend()) {
|
|
|
|
presentWalletHasBalanceAlert();
|
|
|
|
} else {
|
2021-02-25 01:52:55 +01:00
|
|
|
navigateToOverviewAndDeleteWallet();
|
2020-08-09 03:04:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
style: 'destructive',
|
|
|
|
},
|
|
|
|
{ text: loc.wallets.details_no_cancel, onPress: () => {}, style: 'cancel' },
|
|
|
|
],
|
|
|
|
{ cancelable: false },
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-05-04 05:25:18 +02:00
|
|
|
return (
|
|
|
|
<ScrollView
|
|
|
|
contentInsetAdjustmentBehavior="automatic"
|
|
|
|
centerContent={isLoading}
|
|
|
|
contentContainerStyle={styles.scrollViewContent}
|
|
|
|
testID="WalletDetailsScroll"
|
|
|
|
>
|
|
|
|
{isLoading ? (
|
|
|
|
<BlueLoading />
|
|
|
|
) : (
|
|
|
|
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
|
|
|
|
<View>
|
|
|
|
<BlueCard style={styles.address}>
|
|
|
|
<StatusBar barStyle="default" />
|
|
|
|
|
|
|
|
{(() => {
|
|
|
|
if (
|
|
|
|
[LegacyWallet.type, SegwitBech32Wallet.type, SegwitP2SHWallet.type].includes(wallet.type) ||
|
|
|
|
(wallet.type === WatchOnlyWallet.type && !wallet.isHd())
|
|
|
|
) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Text style={[styles.textLabel1, stylesHook.textLabel1]}>{loc.wallets.details_address.toLowerCase()}</Text>
|
|
|
|
<Text style={[styles.textValue, stylesHook.textValue]}>{wallet.getAddress()}</Text>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.add_wallet_name.toLowerCase()}</Text>
|
|
|
|
<KeyboardAvoidingView enabled={!Platform.isPad} behavior={Platform.OS === 'ios' ? 'position' : null}>
|
|
|
|
<View style={[styles.input, stylesHook.input]}>
|
|
|
|
<TextInput
|
|
|
|
placeholder={loc.send.details_note_placeholder}
|
|
|
|
value={walletName}
|
|
|
|
onChangeText={setWalletName}
|
|
|
|
onBlur={walletNameTextInputOnBlur}
|
|
|
|
numberOfLines={1}
|
|
|
|
placeholderTextColor="#81868e"
|
|
|
|
style={styles.inputText}
|
|
|
|
editable={!isLoading}
|
|
|
|
underlineColorAndroid="transparent"
|
|
|
|
testID="WalletNameInput"
|
|
|
|
/>
|
2021-04-21 14:15:34 +02:00
|
|
|
</View>
|
2021-05-04 05:25:18 +02:00
|
|
|
</KeyboardAvoidingView>
|
2020-08-09 03:04:11 +02:00
|
|
|
<BlueSpacing20 />
|
2021-05-04 05:25:18 +02:00
|
|
|
<Text style={[styles.textLabel1, stylesHook.textLabel1]}>{loc.wallets.details_type.toLowerCase()}</Text>
|
|
|
|
<Text style={[styles.textValue, stylesHook.textValue]}>{wallet.typeReadable}</Text>
|
2020-01-02 23:06:51 +01:00
|
|
|
|
2021-09-09 13:00:11 +02:00
|
|
|
{wallet.type === LightningLdkWallet.type && (
|
|
|
|
<>
|
|
|
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.identity_pubkey}</Text>
|
|
|
|
{lightningWalletInfo?.identityPubkey ? (
|
|
|
|
<>
|
|
|
|
<BlueText>{lightningWalletInfo.identityPubkey}</BlueText>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<ActivityIndicator />
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
2020-10-05 23:25:14 +02:00
|
|
|
{wallet.type === MultisigHDWallet.type && (
|
|
|
|
<>
|
2021-05-04 05:25:18 +02:00
|
|
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.details_multisig_type}</Text>
|
|
|
|
<BlueText>
|
|
|
|
{loc.formatString(loc.wallets[`details_ms_${wallet.isNativeSegwit() ? 'ns' : wallet.isWrappedSegwit() ? 'ws' : 'l'}`], {
|
|
|
|
m: wallet.getM(),
|
|
|
|
n: wallet.getN(),
|
|
|
|
})}
|
|
|
|
</BlueText>
|
2020-10-05 23:25:14 +02:00
|
|
|
</>
|
|
|
|
)}
|
2020-10-29 22:13:54 +01:00
|
|
|
{wallet.type === MultisigHDWallet.type && (
|
|
|
|
<>
|
2021-05-04 05:25:18 +02:00
|
|
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.multisig.how_many_signatures_can_bluewallet_make}</Text>
|
|
|
|
<BlueText>{wallet.howManySignaturesCanWeMake()}</BlueText>
|
2020-10-29 22:13:54 +01:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
2021-05-04 05:25:18 +02:00
|
|
|
{wallet.type === LightningCustodianWallet.type && (
|
2020-08-09 03:04:11 +02:00
|
|
|
<>
|
2021-05-04 05:25:18 +02:00
|
|
|
<Text style={[styles.textLabel1, stylesHook.textLabel1]}>{loc.wallets.details_connected_to.toLowerCase()}</Text>
|
|
|
|
<BlueText>{wallet.getBaseURI()}</BlueText>
|
2020-08-09 03:04:11 +02:00
|
|
|
</>
|
|
|
|
)}
|
2021-05-04 05:25:18 +02:00
|
|
|
|
|
|
|
{wallet.type === HDAezeedWallet.type && (
|
2021-03-23 13:16:32 +01:00
|
|
|
<>
|
2021-05-04 05:25:18 +02:00
|
|
|
<Text style={[styles.textLabel1, stylesHook.textLabel1]}>{loc.wallets.identity_pubkey.toLowerCase()}</Text>
|
|
|
|
<BlueText>{wallet.getIdentityPubkey()}</BlueText>
|
2021-03-23 13:16:32 +01:00
|
|
|
</>
|
|
|
|
)}
|
2021-09-09 13:00:11 +02:00
|
|
|
<BlueSpacing20 />
|
2021-05-04 05:25:18 +02:00
|
|
|
<>
|
|
|
|
<Text onPress={exportInternals} style={[styles.textLabel2, stylesHook.textLabel2]}>
|
|
|
|
{loc.transactions.list_title.toLowerCase()}
|
|
|
|
</Text>
|
|
|
|
<View style={styles.hardware}>
|
|
|
|
<BlueText>{loc.wallets.details_display}</BlueText>
|
|
|
|
<Switch value={hideTransactionsInWalletsList} onValueChange={setHideTransactionsInWalletsList} />
|
|
|
|
</View>
|
|
|
|
</>
|
|
|
|
<>
|
|
|
|
<Text onPress={purgeTransactions} style={[styles.textLabel2, stylesHook.textLabel2]}>
|
|
|
|
{loc.transactions.transactions_count.toLowerCase()}
|
|
|
|
</Text>
|
|
|
|
<BlueText>{wallet.getTransactions().length}</BlueText>
|
|
|
|
</>
|
|
|
|
|
|
|
|
<View>
|
|
|
|
{wallet.type === WatchOnlyWallet.type && wallet.isHd() && (
|
|
|
|
<>
|
|
|
|
<BlueSpacing10 />
|
|
|
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.details_advanced.toLowerCase()}</Text>
|
|
|
|
<View style={styles.hardware}>
|
|
|
|
<BlueText>{loc.wallets.details_use_with_hardware_wallet}</BlueText>
|
|
|
|
<Switch value={useWithHardwareWallet} onValueChange={setUseWithHardwareWallet} />
|
|
|
|
</View>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{isAdvancedModeEnabledRender && (
|
|
|
|
<View style={styles.row}>
|
|
|
|
{wallet.allowMasterFingerprint() && (
|
|
|
|
<View style={styles.marginRight16}>
|
|
|
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>
|
|
|
|
{loc.wallets.details_master_fingerprint.toLowerCase()}
|
|
|
|
</Text>
|
|
|
|
<BlueText>{masterFingerprint ?? <ActivityIndicator />}</BlueText>
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
|
2021-09-23 15:05:10 +02:00
|
|
|
{derivationPath && (
|
2021-05-04 05:25:18 +02:00
|
|
|
<View>
|
|
|
|
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.details_derivation_path}</Text>
|
2021-09-23 15:05:10 +02:00
|
|
|
<BlueText testID="DerivationPath">{derivationPath}</BlueText>
|
2021-05-04 05:25:18 +02:00
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</View>
|
|
|
|
)}
|
|
|
|
</View>
|
|
|
|
</BlueCard>
|
|
|
|
{(wallet instanceof AbstractHDElectrumWallet || (wallet.type === WatchOnlyWallet.type && wallet.isHd())) && (
|
|
|
|
<BlueListItem onPress={navigateToAddresses} title={loc.wallets.details_show_addresses} chevron />
|
|
|
|
)}
|
|
|
|
<BlueCard style={styles.address}>
|
|
|
|
<View>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton onPress={navigateToWalletExport} testID="WalletExport" title={loc.wallets.details_export_backup} />
|
|
|
|
|
|
|
|
{wallet.type === MultisigHDWallet.type && (
|
|
|
|
<>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton
|
|
|
|
onPress={navigateToMultisigCoordinationSetup}
|
|
|
|
testID="MultisigCoordinationSetup"
|
|
|
|
title={loc.multisig.export_coordination_setup.replace(/^\w/, c => c.toUpperCase())}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{wallet.type === MultisigHDWallet.type && (
|
|
|
|
<>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton
|
|
|
|
onPress={navigateToViewEditCosigners}
|
|
|
|
testID="ViewEditCosigners"
|
|
|
|
title={loc.multisig.view_edit_cosigners}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{wallet.allowXpub() && (
|
|
|
|
<>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton onPress={navigateToXPub} testID="XPub" title={loc.wallets.details_show_xpub} />
|
|
|
|
{renderMarketplaceButton()}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{wallet.allowSignVerifyMessage() && (
|
|
|
|
<>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton onPress={navigateToSignVerify} testID="SignVerify" title={loc.addresses.sign_title} />
|
|
|
|
</>
|
|
|
|
)}
|
2021-09-09 13:00:11 +02:00
|
|
|
{wallet.type === LightningLdkWallet.type && (
|
|
|
|
<>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<SecondButton onPress={navigateToLdkViewLogs} testID="LdkLogs" title={loc.lnd.view_logs} />
|
|
|
|
</>
|
|
|
|
)}
|
2021-05-04 05:25:18 +02:00
|
|
|
<BlueSpacing20 />
|
|
|
|
<BlueSpacing20 />
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" onPress={handleDeleteButtonTapped} testID="DeleteButton">
|
2021-05-04 05:25:18 +02:00
|
|
|
<Text textBreakStrategy="simple" style={styles.delete}>{`${loc.wallets.details_delete}${' '}`}</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
</BlueCard>
|
|
|
|
</View>
|
|
|
|
</TouchableWithoutFeedback>
|
|
|
|
)}
|
|
|
|
</ScrollView>
|
2020-08-09 03:04:11 +02:00
|
|
|
);
|
|
|
|
};
|
2018-03-18 03:48:23 +01:00
|
|
|
|
2021-09-14 07:36:00 +02:00
|
|
|
WalletDetails.navigationOptions = navigationStyle({}, opts => ({ ...opts, headerTitle: loc.wallets.details_title }));
|
2020-07-15 19:32:59 +02:00
|
|
|
|
2020-08-09 03:04:11 +02:00
|
|
|
export default WalletDetails;
|