()
| 105 | type RouteProps = RouteProp<AddWalletStackParamList, 'AddWallet'>; |
| 106 | |
| 107 | const WalletsAdd: React.FC = () => { |
| 108 | const { colors } = useTheme(); |
| 109 | const layoutTransition = useMemo(() => Layout.springify().damping(16).stiffness(180), []); |
| 110 | |
| 111 | // State |
| 112 | const [state, dispatch] = useReducer(walletReducer, initialState); |
| 113 | const [backdoorPressed, setBackdoorPressed] = useState(0); |
| 114 | const isLoading = state.isLoading; |
| 115 | const walletBaseURI = state.walletBaseURI; |
| 116 | const selectedIndex = state.selectedIndex; |
| 117 | const label = state.label; |
| 118 | const selectedWalletType = state.selectedWalletType; |
| 119 | const colorScheme = useColorScheme(); |
| 120 | // |
| 121 | const { addWallet, saveToDisk } = useStorage(); |
| 122 | const { entropy: entropyHex, words } = useRoute<RouteProps>().params || {}; |
| 123 | const entropy = entropyHex ? hexToUint8Array(entropyHex) : undefined; |
| 124 | const { navigate, goBack, setOptions, setParams } = useExtendedNavigation<NavigationProps>(); |
| 125 | const stylesHook = { |
| 126 | advancedText: { |
| 127 | color: colors.feeText, |
| 128 | }, |
| 129 | label: { |
| 130 | borderColor: colors.formBorder, |
| 131 | borderBottomColor: colors.formBorder, |
| 132 | backgroundColor: colors.inputBackgroundColor, |
| 133 | }, |
| 134 | noPadding: { |
| 135 | backgroundColor: colors.elevated, |
| 136 | }, |
| 137 | root: { |
| 138 | backgroundColor: colors.elevated, |
| 139 | }, |
| 140 | lndUri: { |
| 141 | borderColor: colors.formBorder, |
| 142 | borderBottomColor: colors.formBorder, |
| 143 | backgroundColor: colors.inputBackgroundColor, |
| 144 | }, |
| 145 | }; |
| 146 | |
| 147 | const entropyButtonText = useMemo(() => { |
| 148 | if (!entropy) { |
| 149 | return loc.wallets.add_entropy_provide; |
| 150 | } |
| 151 | return loc.formatString(loc.wallets.add_entropy_bytes, { |
| 152 | bytes: entropy?.length, |
| 153 | }); |
| 154 | }, [entropy]); |
| 155 | |
| 156 | const hasStoredLndHub = (walletBaseURI ?? '').trim().length > 0; |
| 157 | |
| 158 | const confirmResetEntropy = useCallback( |
| 159 | (newWalletType: ButtonSelected) => { |
| 160 | if (entropy || words) { |
| 161 | Alert.alert( |
| 162 | loc.wallets.add_entropy_reset_title, |
| 163 | loc.wallets.add_entropy_reset_message, |
| 164 | [ |
nothing calls this directly
no test coverage detected