fix(clink): route bolt11 through handleAnything to reach payment source screen

This commit is contained in:
Evan Kaloudis
2026-06-08 09:14:38 -04:00
parent deb4c740ac
commit fe7289e64b
4 changed files with 11 additions and 54 deletions
@@ -327,10 +327,7 @@ export default class LightningSwipeableRow extends Component<
const { settings } = settingsStore;
if (clinkNoffer) {
this.props.navigation.navigate('ClinkPay', {
noffer: clinkNoffer,
ecash:
BackendUtils.supportsCashuWallet() &&
settings?.ecash?.enableCashu
noffer: clinkNoffer
});
} else if (offer) {
this.props.navigation.navigate('Send', {
+2 -2
View File
@@ -274,7 +274,7 @@ const handleAnything = async (
if (!AddressUtils.isValidNoffer(clinkNoffer)) {
throw new Error(localeString('utils.handleAnything.invalidNoffer'));
}
return ['ClinkPay', { noffer: clinkNoffer, ecash }];
return ['ClinkPay', { noffer: clinkNoffer }];
} else if (offer) {
if (isClipboardValue) return true;
return [
@@ -400,7 +400,7 @@ const handleAnything = async (
];
} else if (!hasAt && AddressUtils.isValidNoffer(value)) {
if (isClipboardValue) return true;
return ['ClinkPay', { noffer: value, ecash }];
return ['ClinkPay', { noffer: value }];
} else if (value.includes('clnrest://') || value.includes('clnrest+')) {
if (isClipboardValue) return true;
const { host, port, rune, implementation, enableTor } =
+7 -42
View File
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Alert, StyleSheet, Text, View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { inject, observer } from 'mobx-react';
import { observer } from 'mobx-react';
import { Route } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
// @ts-ignore:next-line
@@ -13,9 +13,6 @@ import Header from '../../components/Header';
import LoadingIndicator from '../../components/LoadingIndicator';
import Screen from '../../components/Screen';
import CashuStore from '../../stores/CashuStore';
import InvoicesStore from '../../stores/InvoicesStore';
import ClinkUtils, {
ClinkRequestError,
NofferData,
@@ -24,21 +21,14 @@ import ClinkUtils, {
isNofferSuccess
} from '../../utils/ClinkUtils';
import { errorToUserFriendly } from '../../utils/ErrorUtils';
import handleAnything from '../../utils/handleAnything';
import { localeString } from '../../utils/LocaleUtils';
import { themeColor } from '../../utils/ThemeUtils';
import { getAmountFromSats } from '../../utils/AmountUtils';
interface ClinkPayProps {
navigation: NativeStackNavigationProp<any, any>;
InvoicesStore: InvoicesStore;
CashuStore: CashuStore;
route: Route<
'ClinkPay',
{
noffer: string;
ecash?: boolean;
}
>;
route: Route<'ClinkPay', { noffer: string }>;
}
interface ClinkPayState {
@@ -107,7 +97,6 @@ const errorCodeToLocaleKey = (code?: NofferErrorCode): string | null => {
}
};
@inject('InvoicesStore', 'CashuStore')
@observer
export default class ClinkPay extends React.Component<
ClinkPayProps,
@@ -154,8 +143,7 @@ export default class ClinkPay extends React.Component<
}
confirm = async () => {
const { navigation, InvoicesStore, CashuStore, route } = this.props;
const ecash = route.params?.ecash;
const { navigation } = this.props;
const { nofferData, satAmount } = this.state;
if (!nofferData) return;
@@ -235,32 +223,9 @@ export default class ClinkPay extends React.Component<
}
try {
if (ecash) {
// Load both stores so ChoosePaymentMethod can offer the
// Lightning and ecash routes side-by-side. Mirrors LnurlPay.
await Promise.all([
InvoicesStore.getPayReq(res.bolt11),
CashuStore.getPayReq(res.bolt11)
]);
this.setState({ loading: false });
if (CashuStore.getPayReqError) {
Alert.alert(
localeString('views.ClinkPay.title'),
CashuStore.getPayReqError,
[{ text: localeString('general.ok') }],
{ cancelable: false }
);
return;
}
navigation.navigate('ChoosePaymentMethod', {
lightning: res.bolt11,
locked: true
});
} else {
await InvoicesStore.getPayReq(res.bolt11);
this.setState({ loading: false });
navigation.navigate('PaymentRequest');
}
const [route, params] = await handleAnything(res.bolt11);
this.setState({ loading: false });
navigation.navigate(route, params);
} catch (e: any) {
this.setState({ loading: false });
Alert.alert(
+1 -6
View File
@@ -19,7 +19,6 @@ import Header from '../../components/Header';
import { ContactAvatar } from '../../components/ContactAvatar';
import { confirmAction } from '../../utils/ActionUtils';
import BackendUtils from '../../utils/BackendUtils';
import { localeString } from '../../utils/LocaleUtils';
import { themeColor } from '../../utils/ThemeUtils';
@@ -28,7 +27,6 @@ import Storage from '../../storage';
import Contact from '../../models/Contact';
import ContactStore, { CONTACTS_KEY } from '../../stores/ContactStore';
import { settingsStore } from '../../stores/Stores';
import Add from '../../assets/images/SVG/Add.svg';
import NostrichIcon from '../../assets/images/SVG/Nostrich.svg';
@@ -200,10 +198,7 @@ export default class Contacts extends React.Component<
});
} else if (contact.isSingleNoffer) {
this.props.navigation.navigate('ClinkPay', {
noffer: item.noffer[0],
ecash:
BackendUtils.supportsCashuWallet() &&
settingsStore?.settings?.ecash?.enableCashu
noffer: item.noffer[0]
});
} else if (contact.isSingleOnchainAddress) {
this.props.navigation.navigate('Send', {