Browse Source

ADD: Alert user if they are trying to create a lightning wallet without a bitcoin wallet

zigzag
Marcos Rodriguez Vélez 6 years ago
parent
commit
5a751617d3
  1. 5
      BlueComponents.js
  2. 3
      loc/cs_CZ.js
  3. 3
      loc/da_DK.js
  4. 4
      loc/de_DE.js
  5. 3
      loc/en.js
  6. 4
      loc/es.js
  7. 4
      loc/fr_FR.js
  8. 3
      loc/nl_NL.js
  9. 4
      loc/pt_BR.js
  10. 4
      loc/pt_PT.js
  11. 4
      loc/ru.js
  12. 4
      loc/th_TH.js
  13. 4
      loc/ua.js
  14. 89
      screen/wallets/add.js

5
BlueComponents.js

@ -106,6 +106,7 @@ export class LightningButton extends Component {
render() {
return (
<TouchableOpacity
disabled={this.props.disabled}
onPress={() => {
// eslint-disable-next-line
if (this.props.onPress) this.props.onPress();
@ -136,6 +137,10 @@ export class LightningButton extends Component {
}
}
LightningButton.propTypes = {
disabled: PropTypes.bool,
};
export class BlueButtonLink extends Component {
render() {
// eslint-disable-next-line

3
loc/cs_CZ.js

@ -8,10 +8,13 @@ module.exports = {
hours_ago: 'hodin',
minutes_ago: 'minut',
never: 'nikdy',
continue: 'Continue',
ok: 'OK',
},
wallets: {
select_wallet: 'Vyberte peněženku',
options: 'možnosti',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'Blue Wallet',
title: 'peněženky',

3
loc/da_DK.js

@ -8,10 +8,13 @@ module.exports = {
hours_ago: 'timer siden',
minutes_ago: 'minutter siden',
never: 'aldrig',
continue: 'Continue',
ok: 'OK',
},
wallets: {
select_wallet: 'Vælg wallet',
options: 'valgmuligheder',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'Blue Wallet',
title: 'wallets',

4
loc/de_DE.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'Stunden zurück',
minutes_ago: 'Minuten zurück',
never: 'nie',
continue: 'Continue',
ok: 'OK',
},
wallets: {
select_wallet: 'Wähle Wallet',
options: 'Einstellungen',
createBitcoinWallet:
'In order to use a Lightning wallet, a Bitcoin wallet is needed in order to fund it. Please, create or import a Bitcoin wallet.',
list: {
app_name: 'Blue Wallet',
title: 'Wallets',

3
loc/en.js

@ -8,10 +8,13 @@ module.exports = {
hours_ago: 'hours ago',
minutes_ago: 'minutes ago',
never: 'never',
continue: 'Continue',
ok: 'OK',
},
wallets: {
select_wallet: 'Select Wallet',
options: 'options',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'Blue Wallet',
title: 'wallets',

4
loc/es.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'horas atras',
minutes_ago: 'minutos atras',
never: 'nunca',
continue: 'Continua',
ok: 'OK',
},
wallets: {
options: 'opciones',
select_wallet: 'Selecciona billetera',
createBitcoinWallet:
'In order to use a Lightning wallet, a Bitcoin wallet is needed in order to fund it. Would you like to continue anyway?',
list: {
app_name: 'Blue Wallet',
title: 'billeteras',

4
loc/fr_FR.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'heures',
minutes_ago: 'minutes',
never: 'jamais',
continue: 'Continue',
ok: 'OK',
},
wallets: {
select_wallet: 'Choix du portefeuille',
options: 'options',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'Blue Wallet',
title: 'portefeuilles',

3
loc/nl_NL.js

@ -8,10 +8,13 @@ module.exports = {
hours_ago: 'uur geleden',
minutes_ago: 'minuten geleden',
never: 'nooit',
continue: 'Continue',
ok: 'OK',
},
wallets: {
select_wallet: 'Selecteer portemonnee',
options: 'opties',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'Blue Wallet',
title: 'portemonnees',

4
loc/pt_BR.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'horas atrás',
minutes_ago: 'minutos atrás',
never: 'nunca',
continue: 'Continue',
ok: 'OK',
},
wallets: {
options: 'opções',
select_wallet: 'Escolher carteira',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
tabBarLabel: 'Carteiras',
app_name: 'Blue Wallet',

4
loc/pt_PT.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'hours ago',
minutes_ago: 'minutes ago',
never: 'never',
continue: 'Continue',
ok: 'OK',
},
wallets: {
options: 'options',
select_wallet: 'Select Wallet',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'Blue Wallet',
title: 'wallets',

4
loc/ru.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'часов назад',
minutes_ago: 'минут назад',
never: 'никогда',
continue: 'Continue',
ok: 'OK',
},
wallets: {
options: 'options',
select_wallet: 'Select Wallet',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'BlueWallet',
title: 'кошельки',

4
loc/th_TH.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'ชั่วโมงที่แล้ว',
minutes_ago: 'นาทีที่แล้ว',
never: 'ไม่เคย',
continue: 'Continue',
ok: 'OK',
},
wallets: {
select_wallet: 'เลือกกระเป๋าสตางค์',
options: 'ทางเลือก',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'บูลวอลเล็ต',
title: 'กระเป๋าสตางค์',

4
loc/ua.js

@ -8,10 +8,14 @@ module.exports = {
hours_ago: 'часів тому',
minutes_ago: 'мінут тому',
never: 'ніколи',
continue: 'Continue',
ok: 'OK',
},
wallets: {
options: 'options',
select_wallet: 'Select Wallet',
createBitcoinWallet: 'In order to use a Lightning wallet, a Bitcoin wallet is needed to fund it. Would you like to continue anyway?',
list: {
app_name: 'BlueWallet',
title: 'гаманці',

89
screen/wallets/add.js

@ -1,6 +1,6 @@
/* global alert */
import React, { Component } from 'react';
import { AsyncStorage, ActivityIndicator, Keyboard, Dimensions, View, TextInput, TouchableWithoutFeedback } from 'react-native';
import { Alert, AsyncStorage, ActivityIndicator, Keyboard, Dimensions, View, TextInput, TouchableWithoutFeedback } from 'react-native';
import {
BlueTextCentered,
BlueText,
@ -140,6 +140,7 @@ export default class WalletsAdd extends Component {
height: (width - 60) / 3,
}}
title={loc.wallets.add.create}
disabled={BlueApp.getWallets().some(wallet => wallet.type === LightningCustodianWallet.type)}
/>
</View>
</View>
@ -193,33 +194,70 @@ export default class WalletsAdd extends Component {
let w;
if (this.state.activeLightning) {
// lightning was selected
// eslint-disable-next-line
for (let t of BlueApp.getWallets()) {
let hasBitcoinWallet = false;
for (let t of BlueApp.getWallets()) {
if (t.type === LightningCustodianWallet.type) {
// already exist
this.setState({ isLoading: false });
return alert('Only 1 Lightning wallet allowed for now');
} else if (t.type !== LightningCustodianWallet.type) {
hasBitcoinWallet = true;
}
}
w = new LightningCustodianWallet();
w.setLabel(this.state.label || w.typeReadable);
this.createLightningWallet = async () => {
w = new LightningCustodianWallet();
w.setLabel(this.state.label || w.typeReadable);
try {
let lndhub = await AsyncStorage.getItem(AppStorage.LNDHUB);
if (lndhub) {
w.setBaseURI(lndhub);
w.init();
try {
let lndhub = await AsyncStorage.getItem(AppStorage.LNDHUB);
if (lndhub) {
w.setBaseURI(lndhub);
w.init();
}
await w.createAccount();
await w.authorize();
} catch (Err) {
this.setState({ isLoading: false });
console.warn('lnd create failure', Err);
// giving app, not adding anything
}
await w.createAccount();
await w.authorize();
} catch (Err) {
this.setState({ isLoading: false });
console.warn('lnd create failure', Err);
// giving app, not adding anything
A(A.ENUM.CREATED_LIGHTNING_WALLET);
await w.generate();
BlueApp.wallets.push(w);
await BlueApp.saveToDisk();
EV(EV.enum.WALLETS_COUNT_CHANGED);
A(A.ENUM.CREATED_WALLET);
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
this.props.navigation.dismiss();
};
if (!hasBitcoinWallet) {
Alert.alert(
loc.wallets.add.lightning,
loc.wallets.createBitcoinWallet,
[
{
text: loc.send.details.cancel,
style: 'cancel',
onPress: () => {
this.setState({ isLoading: false });
},
},
{
text: loc._.ok,
style: 'default',
onPress: () => {
this.createLightningWallet();
},
},
],
{ cancelable: false },
);
} else {
this.createLightningWallet();
}
A(A.ENUM.CREATED_LIGHTNING_WALLET);
} else if (this.state.selectedIndex === 1) {
// btc was selected
// index 1 radio - segwit single address
@ -230,14 +268,15 @@ for (let t of BlueApp.getWallets()) {
w = new HDSegwitP2SHWallet();
w.setLabel((this.state.label || loc.wallets.add.label_new_segwit) + ' HD');
}
await w.generate();
BlueApp.wallets.push(w);
await BlueApp.saveToDisk();
EV(EV.enum.WALLETS_COUNT_CHANGED);
A(A.ENUM.CREATED_WALLET);
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
this.props.navigation.dismiss();
if (this.state.activeBitcoin) {
await w.generate();
BlueApp.wallets.push(w);
await BlueApp.saveToDisk();
EV(EV.enum.WALLETS_COUNT_CHANGED);
A(A.ENUM.CREATED_WALLET);
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
this.props.navigation.dismiss();
}
},
1,
);

Loading…
Cancel
Save