mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
ADD: Alert user if they are trying to create a lightning wallet without a bitcoin wallet
This commit is contained in:
parent
802fadc08d
commit
5a751617d3
14 changed files with 113 additions and 25 deletions
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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: 'кошельки',
|
||||
|
|
|
@ -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: 'กระเป๋าสตางค์',
|
||||
|
|
|
@ -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: 'гаманці',
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue