BlueWallet/screen/wallets/details.js

728 lines
26 KiB
JavaScript
Raw Normal View History

import React, { useEffect, useState, useCallback, useContext, useRef, useMemo, useLayoutEffect } 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,
Platform,
Linking,
StyleSheet,
2021-08-03 03:27:54 +02:00
ScrollView,
InteractionManager,
ActivityIndicator,
2021-05-22 05:36:34 +02:00
I18nManager,
2019-09-27 16:49:56 +02:00
} from 'react-native';
import { BlueCard, BlueLoading, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents';
2020-12-25 17:09:53 +01:00
import navigationStyle from '../../components/navigationStyle';
import { LightningCustodianWallet } from '../../class/wallets/lightning-custodian-wallet';
import Biometric from '../../class/biometrics';
import {
HDSegwitBech32Wallet,
SegwitP2SHWallet,
LegacyWallet,
SegwitBech32Wallet,
WatchOnlyWallet,
MultisigHDWallet,
HDAezeedWallet,
2021-09-09 13:00:11 +02:00
LightningLdkWallet,
} from '../../class';
2022-10-12 18:39:48 +02:00
import loc, { formatBalanceWithoutSuffix } from '../../loc';
2023-10-24 03:28:44 +02:00
import { useRoute, useNavigation } from '@react-navigation/native';
import RNFS from 'react-native-fs';
import Share from 'react-native-share';
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';
import presentAlert from '../../components/Alert';
2022-10-12 18:39:48 +02:00
import { BitcoinUnit, Chain } from '../../models/bitcoinUnits';
import { writeFileAndExport } from '../../blue_modules/fs';
import { PERMISSIONS, RESULTS, request } from 'react-native-permissions';
2023-10-24 03:28:44 +02:00
import { useTheme } from '../../components/themes';
2023-12-16 22:44:35 +01:00
import ListItem from '../../components/ListItem';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import Button from '../../components/Button';
import { SecondButton } from '../../components/SecondButton';
2022-09-05 20:34:02 +02:00
const prompt = require('../../helpers/prompt');
2018-01-30 23:42:38 +01:00
const styles = StyleSheet.create({
scrollViewContent: {
flexGrow: 1,
},
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',
},
textLabel2: {
fontWeight: '500',
fontSize: 14,
marginVertical: 16,
2021-05-22 05:36:34 +02:00
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
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',
},
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',
},
row: {
flexDirection: 'row',
},
marginRight16: {
marginRight: 16,
},
2022-03-20 21:57:16 +01:00
save: {
alignItems: 'center',
justifyContent: 'center',
width: 80,
borderRadius: 8,
height: 34,
},
saveText: {
fontSize: 15,
fontWeight: '600',
},
});
2020-08-09 03:04:11 +02:00
const WalletDetails = () => {
const { saveToDisk, wallets, deleteWallet, setSelectedWalletID, txMetadata } = useContext(BlueStorageContext);
const { walletID } = useRoute().params;
const [isLoading, setIsLoading] = useState(false);
const [backdoorPressed, setBackdoorPressed] = useState(0);
const [backdoorBip47Pressed, setBackdoorBip47Pressed] = useState(0);
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());
2023-03-04 16:30:51 +01:00
const { isAdvancedModeEnabled } = useContext(BlueStorageContext);
const [isAdvancedModeEnabledRender, setIsAdvancedModeEnabledRender] = useState(false);
2022-12-12 03:34:50 +01:00
const [isBIP47Enabled, setIsBIP47Enabled] = useState(wallet.isBIP47Enabled());
2020-08-09 03:04:11 +02:00
const [hideTransactionsInWalletsList, setHideTransactionsInWalletsList] = useState(!wallet.getHideTransactionsInWalletsList());
const { goBack, navigate, setOptions, popToTop } = useNavigation();
2020-08-09 03:04:11 +02:00
const { colors } = useTheme();
const [masterFingerprint, setMasterFingerprint] = useState();
2022-10-12 18:39:48 +02:00
const walletTransactionsLength = useMemo(() => wallet.getTransactions().length, [wallet]);
const derivationPath = useMemo(() => {
try {
const path = wallet.getDerivationPath();
return path.length > 0 ? path : null;
} catch (e) {
return null;
}
}, [wallet]);
2021-09-09 13:00:11 +02:00
const [lightningWalletInfo, setLightningWalletInfo] = useState({});
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,
},
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,
},
2022-03-20 21:57:16 +01:00
save: {
backgroundColor: colors.lightButton,
},
saveText: {
color: colors.buttonTextColor,
},
2020-08-09 03:04:11 +02:00
});
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
2023-03-15 21:42:25 +01:00
const save = () => {
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());
if (wallet.type === WatchOnlyWallet.type && wallet.isHd()) {
2020-08-09 03:04:11 +02:00
wallet.setUseWithHardwareWalletEnabled(useWithHardwareWallet);
}
2020-08-09 03:04:11 +02:00
wallet.setHideTransactionsInWalletsList(!hideTransactionsInWalletsList);
if (wallet.allowBIP47()) {
wallet.switchBIP47(isBIP47Enabled);
}
2020-08-09 03:04:11 +02:00
}
saveToDisk()
.then(() => {
presentAlert({ message: loc.wallets.details_wallet_updated });
goBack();
})
.catch(error => {
console.log(error.message);
setIsLoading(false);
});
};
2018-01-30 23:42:38 +01:00
useLayoutEffect(() => {
2023-03-04 16:30:51 +01:00
isAdvancedModeEnabled().then(setIsAdvancedModeEnabledRender);
setOptions({
// eslint-disable-next-line react/no-unstable-nested-components
headerRight: () => (
2022-03-20 21:57:16 +01:00
<TouchableOpacity
accessibilityRole="button"
testID="Save"
disabled={isLoading}
style={[styles.save, stylesHook.save]}
2023-03-15 21:42:25 +01:00
onPress={save}
2022-03-20 21:57:16 +01:00
>
<Text style={[styles.saveText, stylesHook.saveText]}>{loc.wallets.details_save}</Text>
</TouchableOpacity>
),
});
// eslint-disable-next-line react-hooks/exhaustive-deps
2022-12-07 02:13:45 +01:00
}, [isLoading, colors, walletName, useWithHardwareWallet, hideTransactionsInWalletsList, isBIP47Enabled]);
2020-08-09 03:04:11 +02:00
useEffect(() => {
if (wallets.some(w => w.getID() === walletID)) {
setSelectedWalletID(walletID);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [walletID]);
2021-02-25 01:52:55 +01:00
const navigateToOverviewAndDeleteWallet = () => {
setIsLoading(true);
let externalAddresses = [];
try {
externalAddresses = wallet.getAllExternalAddresses();
} catch (_) {}
Notifications.unsubscribe(externalAddresses, [], []);
2021-02-25 01:52:55 +01:00
popToTop();
deleteWallet(wallet);
2021-09-07 21:30:07 +02:00
saveToDisk(true);
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
2021-02-25 01:52:55 +01:00
};
2020-08-09 03:04:11 +02:00
const presentWalletHasBalanceAlert = useCallback(async () => {
triggerHapticFeedback(HapticFeedbackTypes.NotificationWarning);
try {
const walletBalanceConfirmation = await prompt(
loc.wallets.details_delete_wallet,
loc.formatString(loc.wallets.details_del_wb_q, { balance: wallet.getBalance() }),
true,
'plain-text',
true,
2021-10-16 16:37:51 +02:00
loc.wallets.details_delete,
);
if (Number(walletBalanceConfirmation) === wallet.getBalance()) {
2021-02-25 01:52:55 +01:00
navigateToOverviewAndDeleteWallet();
} else {
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
setIsLoading(false);
presentAlert({ message: loc.wallets.details_del_wb_err });
}
} catch (_) {}
// eslint-disable-next-line react-hooks/exhaustive-deps
2021-02-25 01:52:55 +01:00
}, []);
2020-08-09 03:04:11 +02:00
const navigateToWalletExport = () => {
navigate('WalletExportRoot', {
screen: 'WalletExport',
params: {
walletID: wallet.getID(),
},
});
};
2020-10-05 23:25:14 +02:00
const navigateToMultisigCoordinationSetup = () => {
navigate('ExportMultisigCoordinationSetupRoot', {
screen: 'ExportMultisigCoordinationSetup',
params: {
walletId: wallet.getID(),
},
2020-10-05 23:25:14 +02:00
});
};
const navigateToViewEditCosigners = () => {
2020-12-12 01:27:43 +01:00
navigate('ViewEditMultisigCosignersRoot', {
screen: 'ViewEditMultisigCosigners',
params: {
walletId: wallet.getID(),
},
});
};
2020-08-09 03:04:11 +02:00
const navigateToXPub = () =>
navigate('WalletXpubRoot', {
screen: 'WalletXpub',
params: {
2021-06-17 23:24:00 +02:00
walletID,
},
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,
});
};
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
});
2023-03-15 21:42:25 +01:00
const navigateToPaymentCodes = () =>
navigate('PaymentCodeRoot', {
screen: 'PaymentCodesList',
params: {
walletID: wallet.getID(),
},
});
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,
})
.catch(error => {
console.log(error);
presentAlert({ message: error.message });
})
.finally(() => {
RNFS.unlink(filePath);
});
} else if (Platform.OS === 'android') {
const granted = await request(PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);
if (granted === RESULTS.GRANTED) {
console.log('Storage Permission: Granted');
const filePath = RNFS.DownloadDirectoryPath + `/${fileName}`;
try {
await RNFS.writeFile(filePath, contents);
presentAlert({ message: loc.formatString(loc.send.txSaved, { filePath: fileName }) });
} catch (e) {
console.log(e);
presentAlert({ message: e.message });
}
} else {
console.log('Storage Permission: Denied');
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' },
]);
}
}
};
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 = {};
presentAlert({ message: msg });
}
if (wallet._hdWalletInstance) {
wallet._hdWalletInstance._txs_by_external_index = {};
wallet._hdWalletInstance._txs_by_internal_index = {};
presentAlert({ message: 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
2022-10-12 18:39:48 +02:00
const onExportHistoryPressed = async () => {
const csvFileArray = [
2022-10-12 18:39:48 +02:00
loc.transactions.date,
loc.transactions.txid,
`${loc.send.create_amount} (${BitcoinUnit.BTC})`,
loc.send.create_memo,
];
if (wallet.chain === Chain.OFFCHAIN) {
csvFileArray.push(loc.lnd.payment);
}
let csvFile = csvFileArray.join(','); // CSV header
2022-10-12 18:39:48 +02:00
const transactions = wallet.getTransactions();
for (const transaction of transactions) {
const value = formatBalanceWithoutSuffix(transaction.value, BitcoinUnit.BTC, true);
let hash = transaction.hash;
let memo = txMetadata[transaction.hash]?.memo?.trim() ?? '';
let status;
if (wallet.chain === Chain.OFFCHAIN) {
hash = transaction.payment_hash;
memo = transaction.description;
status = transaction.ispaid ? loc._.success : loc.lnd.expired;
2023-04-28 12:29:15 +02:00
if (hash?.type === 'Buffer' && hash?.data) {
const bb = Buffer.from(hash);
hash = bb.toString('hex');
}
}
const data = [new Date(transaction.received).toString(), hash, value, memo];
if (wallet.chain === Chain.OFFCHAIN) {
data.push(status);
}
csvFile += '\n' + data.join(','); // CSV line
2022-10-12 18:39:48 +02:00
}
await writeFileAndExport(`${wallet.label.replace(' ', '-')}-history.csv`, csvFile);
};
2020-08-09 03:04:11 +02:00
const handleDeleteButtonTapped = () => {
triggerHapticFeedback(HapticFeedbackTypes.NotificationWarning);
2020-08-09 03:04:11 +02:00
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 },
);
};
return (
<ScrollView
contentInsetAdjustmentBehavior="automatic"
centerContent={isLoading}
contentContainerStyle={styles.scrollViewContent}
testID="WalletDetailsScroll"
>
{isLoading ? (
<BlueLoading />
) : (
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View>
<BlueCard style={styles.address}>
{(() => {
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]}>
{(() => {
// gracefully handling faulty wallets, so at least user has an option to delete the wallet
try {
return wallet.getAddress();
} catch (error) {
return error.message;
}
})()}
</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
value={walletName}
onChangeText={setWalletName}
onBlur={walletNameTextInputOnBlur}
numberOfLines={1}
placeholderTextColor="#81868e"
style={styles.inputText}
editable={!isLoading}
underlineColorAndroid="transparent"
testID="WalletNameInput"
/>
</View>
</KeyboardAvoidingView>
2020-08-09 03:04:11 +02:00
<BlueSpacing20 />
<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 && (
<>
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.details_multisig_type}</Text>
<BlueText>
{`${wallet.getM()} / ${wallet.getN()} (${
wallet.isNativeSegwit() ? 'native segwit' : wallet.isWrappedSegwit() ? 'wrapped segwit' : 'legacy'
})`}
</BlueText>
2020-10-05 23:25:14 +02:00
</>
)}
{wallet.type === MultisigHDWallet.type && (
<>
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.multisig.how_many_signatures_can_bluewallet_make}</Text>
<BlueText>{wallet.howManySignaturesCanWeMake()}</BlueText>
</>
)}
{wallet.type === LightningCustodianWallet.type && (
2020-08-09 03:04:11 +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
</>
)}
{wallet.type === HDAezeedWallet.type && (
2021-03-23 13:16:32 +01: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 />
<>
<Text onPress={exportInternals} style={[styles.textLabel2, stylesHook.textLabel2]}>
{loc.transactions.list_title.toLowerCase()}
</Text>
<View style={styles.hardware}>
<BlueText onPress={() => setBackdoorBip47Pressed(prevState => prevState + 1)}>{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>
</>
{backdoorBip47Pressed >= 10 && wallet.allowBIP47() ? (
2023-03-15 21:42:25 +01:00
<>
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.bip47.payment_code}</Text>
<View style={styles.hardware}>
<BlueText>{loc.bip47.purpose}</BlueText>
<Switch value={isBIP47Enabled} onValueChange={setIsBIP47Enabled} />
</View>
</>
) : null}
2022-12-07 01:56:11 +01:00
<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>
)}
{derivationPath && (
<View>
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.details_derivation_path}</Text>
<BlueText testID="DerivationPath">{derivationPath}</BlueText>
</View>
)}
</View>
)}
</View>
</BlueCard>
{(wallet instanceof AbstractHDElectrumWallet || (wallet.type === WatchOnlyWallet.type && wallet.isHd())) && (
2023-12-16 22:44:35 +01:00
<ListItem onPress={navigateToAddresses} title={loc.wallets.details_show_addresses} chevron />
)}
2023-12-16 22:44:35 +01:00
{wallet.allowBIP47() && isBIP47Enabled && <ListItem onPress={navigateToPaymentCodes} title="Show payment codes" chevron />}
<BlueCard style={styles.address}>
<View>
<BlueSpacing20 />
<Button onPress={navigateToWalletExport} testID="WalletExport" title={loc.wallets.details_export_backup} />
{walletTransactionsLength > 0 && (
2022-10-12 18:39:48 +02:00
<>
<BlueSpacing20 />
<SecondButton onPress={onExportHistoryPressed} title={loc.wallets.details_export_history} />
</>
)}
{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} />
</>
)}
{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} />
</>
)}
<BlueSpacing20 />
<BlueSpacing20 />
<TouchableOpacity accessibilityRole="button" onPress={handleDeleteButtonTapped} testID="DeleteButton">
<Text textBreakStrategy="simple" style={styles.delete}>{`${loc.wallets.details_delete}${' '}`}</Text>
</TouchableOpacity>
2023-12-13 12:58:04 +01:00
<BlueSpacing20 />
<BlueSpacing20 />
</View>
</BlueCard>
</View>
</TouchableWithoutFeedback>
)}
</ScrollView>
2020-08-09 03:04:11 +02:00
);
};
2018-03-18 03:48:23 +01:00
2023-10-20 04:28:49 +02:00
WalletDetails.navigationOptions = navigationStyle({}, opts => ({
...opts,
headerTitle: loc.wallets.details_title,
statusBarStyle: 'auto',
}));
2020-07-15 19:32:59 +02:00
2020-08-09 03:04:11 +02:00
export default WalletDetails;