Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlueWallet LndHub.io warning message #1358

Merged
merged 2 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -539,6 +539,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 @@ -486,9 +486,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 @@ -508,10 +514,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