This commit is contained in:
Marcos Rodriguez Vélez 2021-07-08 13:39:03 -04:00
parent f7c264e36e
commit e5c4730cc9
6 changed files with 18 additions and 25 deletions

View file

@ -391,8 +391,7 @@ export class AppStorage {
console.log('using wallet-wide settings ', lndhub, 'for ln wallet');
unserializedWallet.setBaseURI(lndhub);
} else {
console.log('using default', LightningCustodianWallet.defaultBaseUri, 'for ln wallet');
unserializedWallet.setBaseURI(LightningCustodianWallet.defaultBaseUri);
console.log('wallet does not have a baseURI. Continuing init...');
}
unserializedWallet.init();
break;

View file

@ -147,9 +147,6 @@ function WalletImport() {
const split = importText.split('@');
lnd.setBaseURI(split[1]);
lnd.setSecret(split[0]);
} else {
lnd.setBaseURI(LightningCustodianWallet.defaultBaseUri);
lnd.setSecret(importText);
}
lnd.init();
await lnd.authorize();

View file

@ -7,7 +7,7 @@ const torrific = require('../../blue_modules/torrific');
export class LightningCustodianWallet extends LegacyWallet {
static type = 'lightningCustodianWallet';
static typeReadable = 'Lightning';
static defaultBaseUri = 'https://lndhub.herokuapp.com/';
constructor(props) {
super(props);
this.setBaseURI(); // no args to init with default value
@ -30,11 +30,7 @@ export class LightningCustodianWallet extends LegacyWallet {
* @param URI
*/
setBaseURI(URI) {
if (URI) {
this.baseURI = URI;
} else {
this.baseURI = LightningCustodianWallet.defaultBaseUri;
}
this.baseURI = URI;
}
getBaseURI() {
@ -54,9 +50,6 @@ export class LightningCustodianWallet extends LegacyWallet {
}
getSecret() {
if (this.baseURI === LightningCustodianWallet.defaultBaseUri) {
return this.secret;
}
return this.secret + '@' + this.baseURI;
}
@ -79,7 +72,7 @@ export class LightningCustodianWallet extends LegacyWallet {
baseURI: this.baseURI,
});
if (this.baseURI.indexOf('.onion') !== -1) {
if (this.baseURI?.indexOf('.onion') !== -1) {
this._api = new torrific.Torsbee({
baseURI: this.baseURI,
});

View file

@ -133,8 +133,11 @@ const LightningSettings = () => {
<BlueCard>
<View style={styles.uri}>
<TextInput
placeholder={LightningCustodianWallet.defaultBaseUri}
value={URI}
placeholder={
loc.formatString(loc.settings.electrum_host, { example: '111.222.333.111' }) +
(!isDesktop ? ' (' + loc.settings.tor_supported + ')' : '')
}
onChangeText={setLndhubURI}
numberOfLines={1}
style={styles.uriText}
@ -148,8 +151,6 @@ const LightningSettings = () => {
/>
</View>
<BlueSpacing20 />
{!isDesktop && <BlueText style={[styles.torSupported]}>{loc.settings.tor_supported}</BlueText>}
<BlueSpacing20 />
<BlueButtonLink title={loc.wallets.import_scan_qr} testID="ImportScan" onPress={importScan} />
<BlueSpacing20 />
{isLoading ? <BlueLoading /> : <BlueButton testID="Save" onPress={save} title={loc.settings.save} />}

View file

@ -43,7 +43,7 @@ const WalletsAdd = () => {
const { colors } = useTheme();
const { addWallet, saveToDisk, isAdancedModeEnabled } = useContext(BlueStorageContext);
const [isLoading, setIsLoading] = useState(true);
const [walletBaseURI, setWalletBaseURI] = useState();
const [walletBaseURI, setWalletBaseURI] = useState('');
const [selectedIndex, setSelectedIndex] = useState(0);
const [label, setLabel] = useState('');
const [isAdvancedOptionsEnabled, setIsAdvancedOptionsEnabled] = useState(false);
@ -160,7 +160,7 @@ const WalletsAdd = () => {
wallet.setLabel(label || loc.wallets.details_title);
try {
const lndhub = walletBaseURI && walletBaseURI.trim().length > 0 ? walletBaseURI : LightningCustodianWallet.defaultBaseUri;
const lndhub = walletBaseURI?.trim();
if (lndhub) {
const isValidNodeAddress = await LightningCustodianWallet.isValidNodeAddress(lndhub);
if (isValidNodeAddress) {
@ -277,7 +277,7 @@ const WalletsAdd = () => {
/>
</View>
);
} else if (selectedWalletType === ButtonSelected.OFFCHAIN && isAdvancedOptionsEnabled) {
} else if (selectedWalletType === ButtonSelected.OFFCHAIN) {
return (
<>
<BlueSpacing20 />
@ -310,7 +310,12 @@ const WalletsAdd = () => {
<BlueSpacing20 />
<View style={styles.createButton}>
{!isLoading ? (
<BlueButton testID="Create" title={loc.wallets.add_create} disabled={!selectedWalletType} onPress={createWallet} />
<BlueButton
testID="Create"
title={loc.wallets.add_create}
disabled={!selectedWalletType || (selectedWalletType === Chain.OFFCHAIN && (walletBaseURI ?? '').trim().length === 0)}
onPress={createWallet}
/>
) : (
<ActivityIndicator />
)}

View file

@ -4,12 +4,11 @@ import { View, StyleSheet, BackHandler, StatusBar } from 'react-native';
import QRCode from 'react-native-qrcode-svg';
import { ScrollView } from 'react-native-gesture-handler';
import { BlueButton, BlueCopyTextToClipboard, BlueSpacing20, BlueText, BlueTextCentered, SafeBlueArea } from '../../BlueComponents';
import { BlueButton, BlueCopyTextToClipboard, BlueSpacing20, BlueTextCentered, SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../blue_modules/Privacy';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { LightningCustodianWallet } from '../../class';
const PleaseBackupLNDHub = () => {
const { wallets } = useContext(BlueStorageContext);
@ -59,7 +58,6 @@ const PleaseBackupLNDHub = () => {
<View>
<BlueTextCentered>{loc.pleasebackup.text_lnd}</BlueTextCentered>
<BlueSpacing20 />
{wallet.getBaseURI() === LightningCustodianWallet.defaultBaseUri && <BlueText>- {loc.pleasebackup.text_lnd2}</BlueText>}
</View>
<BlueSpacing20 />
<View style={styles.qrCodeContainer}>