From 5b09775fdaa465627ba8bb88a5f94529c74165d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20V=C3=A9lez?= Date: Wed, 25 Aug 2021 16:35:25 -0400 Subject: [PATCH 1/2] FIX: If offline mode, disable import button --- screen/wallets/import.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/screen/wallets/import.js b/screen/wallets/import.js index 7b4ac4c79..46a3d0bab 100644 --- a/screen/wallets/import.js +++ b/screen/wallets/import.js @@ -23,7 +23,7 @@ const fs = require('../../blue_modules/fs'); const WalletsImport = () => { const [isToolbarVisibleForAndroid, setIsToolbarVisibleForAndroid] = useState(false); const route = useRoute(); - const { isImportingWallet } = useContext(BlueStorageContext); + const { isImportingWallet, isElectrumDisabled } = useContext(BlueStorageContext); const label = (route.params && route.params.label) || ''; const triggerImport = (route.params && route.params.triggerImport) || false; const [importText, setImportText] = useState(label); @@ -141,6 +141,21 @@ const WalletsImport = () => { } }; + const isImportDisabled = () => { + let disabled = false; + const seed = importText.trim(); + + if (seed.length === 0) { + disabled = true; + } + + if (!seed.startsWith('lndhub://') && isElectrumDisabled) { + disabled = true; + } + + return disabled; + }; + return ( @@ -158,12 +173,7 @@ const WalletsImport = () => { <> - + From 881d8fa9aa109980c85bce20d32025008eb99808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20V=C3=A9lez?= Date: Wed, 25 Aug 2021 17:09:41 -0400 Subject: [PATCH 2/2] Update import.js --- screen/wallets/import.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/screen/wallets/import.js b/screen/wallets/import.js index 46a3d0bab..b8544bb3b 100644 --- a/screen/wallets/import.js +++ b/screen/wallets/import.js @@ -1,3 +1,4 @@ +/* global alert */ import React, { useContext, useEffect, useState } from 'react'; import { Platform, View, Keyboard, StatusBar, StyleSheet, Alert } from 'react-native'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; @@ -19,6 +20,7 @@ import { isDesktop, isMacCatalina } from '../../blue_modules/environment'; import { BlueStorageContext } from '../../blue_modules/storage-context'; const fs = require('../../blue_modules/fs'); +const BlueElectrum = require('../../blue_modules/BlueElectrum'); const WalletsImport = () => { const [isToolbarVisibleForAndroid, setIsToolbarVisibleForAndroid] = useState(false); @@ -69,6 +71,13 @@ const WalletsImport = () => { * @param importText */ const importMnemonic = async importText => { + if (!importText.trim().startsWith('lndhub://')) { + const config = await BlueElectrum.getConfig(); + if (config.connected !== 1) { + return alert(loc.settings.electrum_connnected_not_description); + } + } + if (isImportingWallet && isImportingWallet.isFailure === false) { return; }