Skip to content

Commit

Permalink
Merge pull request #1358 from kaloudis/bluewallet-warning
Browse files Browse the repository at this point in the history
BlueWallet LndHub.io warning message
  • Loading branch information
kaloudis authored Mar 17, 2023
2 parents 4855ad7 + 1923a47 commit a5675c5
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 34 deletions.
26 changes: 26 additions & 0 deletions components/BlueWalletWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { View } from 'react-native';
import { ErrorMessage } from './SuccessErrorMessage';
import stores from '../stores/Stores';
import { localeString } from '../utils/LocaleUtils';

export default function BlueWalletWarning() {
const SettingsStore = stores.settingsStore;
const node: any =
SettingsStore.settings.nodes &&
SettingsStore.settings.nodes[SettingsStore.settings.selectedNode || 0];
const isLndHubIo =
node.implementation === 'lndhub' &&
(node.lndhubUrl.includes('https://lndhub.io') ||
node.lndhubUrl.includes('https://lndhub.herokuapp.com'));

if (!isLndHubIo) return;
return (
<View style={{ width: '100%', paddingLeft: 15, paddingRight: 15 }}>
<ErrorMessage
message={localeString('components.BlueWalletWarning.warning')}
link="https://bluewallet.io/sunsetting-lndhub/"
fontSize={15}
/>
</View>
);
}
45 changes: 26 additions & 19 deletions components/LayerBalances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import UnitsStore from './../../stores/UnitsStore';
import BackendUtils from '../../utils/BackendUtils';
import { themeColor } from './../../utils/ThemeUtils';

import BlueWalletWarning from '../../components/BlueWalletWarning';

import OnChainSvg from '../../assets/images/SVG/DynamicSVG/OnChainSvg';
import LightningSvg from '../../assets/images/SVG/DynamicSVG/LightningSvg';

Expand Down Expand Up @@ -126,25 +128,30 @@ export default class LayerBalances extends Component<LayerBalancesProps, {}> {
}

return (
<FlatList
data={DATA}
ItemSeparatorComponent={() => <View style={styles.separator} />}
renderItem={({ item, index }) => (
<SwipeableRow
item={item}
index={index}
navigation={navigation}
// select pay method vars
value={value}
amount={amount}
lightning={lightning}
/>
)}
keyExtractor={(_item, index) => `message ${index}`}
style={{ top: 20 }}
onRefresh={() => onRefresh()}
refreshing={false}
/>
<>
<BlueWalletWarning />
<FlatList
data={DATA}
ItemSeparatorComponent={() => (
<View style={styles.separator} />
)}
renderItem={({ item, index }) => (
<SwipeableRow
item={item}
index={index}
navigation={navigation}
// select pay method vars
value={value}
amount={amount}
lightning={lightning}
/>
)}
keyExtractor={(_item, index) => `message ${index}`}
style={{ top: 20 }}
onRefresh={() => onRefresh()}
refreshing={false}
/>
</>
);
}
}
Expand Down
49 changes: 41 additions & 8 deletions components/SuccessErrorMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
import * as React from 'react';
import { StyleSheet, Text } from 'react-native';
import { StyleSheet, Text, TouchableOpacity } from 'react-native';
import UrlUtils from '../utils/UrlUtils';

interface MessageProps {
message?: string;
fontSize?: number;
link: string;
mainStyle: any;
}

const SuccessMessage = (props: MessageProps) => (
<Text style={[styles.field, styles.successField]}>{props.message}</Text>
const Message = ({ message, fontSize, link, mainStyle }: MessageProps) =>
link ? (
<TouchableOpacity onPress={() => UrlUtils.goToUrl(link)}>
<Text
style={[styles.field, mainStyle, { fontSize: fontSize || 20 }]}
>
{message}
</Text>
</TouchableOpacity>
) : (
<Text style={[styles.field, mainStyle, { fontSize: fontSize || 20 }]}>
{message}
</Text>
);

const SuccessMessage = ({ message, fontSize, link }: MessageProps) => (
<Message
message={message}
fontSize={fontSize}
link={link}
mainStyle={styles.successField}
/>
);

const WarningMessage = (props: MessageProps) => (
<Text style={[styles.field, styles.warningField]}>{props.message}</Text>
const WarningMessage = ({ message, fontSize, link }: MessageProps) => (
<Message
message={message}
fontSize={fontSize}
link={link}
mainStyle={styles.warningField}
/>
);

const ErrorMessage = (props: MessageProps) => (
<Text style={[styles.field, styles.errorField]}>{props.message}</Text>
const ErrorMessage = ({ message, fontSize, link }: MessageProps) => (
<Message
message={message}
fontSize={fontSize}
link={link}
mainStyle={styles.errorField}
/>
);

const styles = StyleSheet.create({
field: {
fontFamily: 'Lato-Regular',
fontSize: 20,
width: '100%',
top: 10,
borderRadius: 6,
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@
"components.ChannelPicker.modal.title": "Select Channel to use",
"components.ChannelPicker.modal.description": "Select the Channel to be used in this operation. You may want to only use specific channels to preserve your privacy.",
"components.ChannelPicker.modal.set": "Set Channel",
"components.BlueWalletWarning.warning": "WARNING: LNDHub.io is shutting down. Move your funds by April 30th or you will lose them.",
"backends.LND.wsReq.warning": "You may have to enable Certificate Verification to make these kind of calls",
"utils.handleAnything.lightningAddressError": "Error fetching Lightning Address data",
"utils.handleAnything.notValid": "Value provided was not a valid Bitcoin address or Lightning Invoice",
Expand Down
28 changes: 22 additions & 6 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,15 @@ export default class SettingsStore {
return doTorRequest(url, RequestMethod.POST)
.then((response: any) => {
this.loading = false;
this.createAccountSuccess = localeString(
'stores.SettingsStore.lndhubSuccess'
);
if (response.error) {
this.createAccountError =
response.message ||
localeString('stores.SettingsStore.lndhubError');
} else {
this.createAccountSuccess = localeString(
'stores.SettingsStore.lndhubSuccess'
);
}
return response;
})
.catch((err: any) => {
Expand All @@ -550,10 +556,20 @@ export default class SettingsStore {
const status = response.info().status;
if (status == 200) {
const data = response.json();
console.log('!!', data);
this.loading = false;
this.createAccountSuccess = localeString(
'stores.SettingsStore.lndhubSuccess'
);
if (data.error) {
this.createAccountError =
data.message ||
localeString(
'stores.SettingsStore.lndhubError'
);
} else {
this.createAccountSuccess = localeString(
'stores.SettingsStore.lndhubSuccess'
);
}

return data;
} else {
// handle error
Expand Down
5 changes: 4 additions & 1 deletion views/Settings/NodeConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,10 @@ export default class NodeConfiguration extends React.Component<
lndhubUrl,
certVerification
).then((data: any) => {
if (data) {
if (
data.login &&
data.password
) {
this.setState({
username:
data.login,
Expand Down

0 comments on commit a5675c5

Please sign in to comment.