Skip to content

Commit

Permalink
fix: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
reneaaron committed Sep 25, 2024
1 parent 177f534 commit 63c3240
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 6 additions & 1 deletion hooks/useHandleLinking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ export function useHandleLinking() {
url: currentUrl,
},
});
break;
return;
}
}

// Code below here is only executed if the link could not be handled
router.replace({
pathname: "/",
});
}, [url, hasNavigationState]);
}
1 change: 0 additions & 1 deletion pages/Wildcard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function Wildcard() {
/>
<Loading />
<Text>Loading</Text>
<Text className="text-muted-foreground">{pathname}</Text>
</View>
);
}
5 changes: 3 additions & 2 deletions pages/send/LNURLPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { DualCurrencyInput } from "~/components/DualCurrencyInput";
import DismissableKeyboardView from "~/components/DismissableKeyboardView";

export function LNURLPay() {
const { lnurlDetailsJSON, originalText } =
const { lnurlDetailsJSON, originalText, humanReadablePaymentInfo } =
useLocalSearchParams() as unknown as {
lnurlDetailsJSON: string;
originalText: string;
humanReadablePaymentInfo: string;
};
const lnurlDetails: LNURLPayServiceResponse = JSON.parse(lnurlDetailsJSON);
const [isLoading, setLoading] = React.useState(false);
Expand Down Expand Up @@ -85,7 +86,7 @@ export function LNURLPay() {
To
</Text>
<Text className="text-center text-foreground text-2xl font-medium2">
{originalText.toLowerCase().replace("lightning:", "")}
{humanReadablePaymentInfo}
</Text>
</View>
</View>
Expand Down
9 changes: 8 additions & 1 deletion pages/send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function Send() {
}
console.log("loading payment", text);
const originalText = text;
let humanReadablePaymentInfo = text;
setLoading(true);
try {
if (text.startsWith("bitcoin:")) {
Expand All @@ -88,6 +89,7 @@ export function Send() {
if (text.startsWith("lightning:")) {
text = text.substring("lightning:".length);
}

const lnurlValue = lnurl.findLnurl(text);
console.log("Checked lnurl value", text, lnurlValue);
if (lnurlValue) {
Expand All @@ -97,6 +99,8 @@ export function Send() {
throw new Error("LNURL tag " + lnurlDetails.tag + " not supported");
}

humanReadablePaymentInfo = lnurlValue;

// Handle fixed amount LNURLs
if (lnurlDetails.minSendable === lnurlDetails.maxSendable && !lnurlDetails.commentAllowed) {
try {
Expand All @@ -117,20 +121,23 @@ export function Send() {
params: {
lnurlDetailsJSON: JSON.stringify(lnurlDetails),
originalText,
humanReadablePaymentInfo
},
});
}

return true;
} else {
humanReadablePaymentInfo = text;

// Check if this is a valid invoice
new Invoice({
pr: text,
});

router.replace({
pathname: "/send/confirm",
params: { invoice: text, originalText },
params: { invoice: text, originalText, humanReadablePaymentInfo },
});

return true;
Expand Down

0 comments on commit 63c3240

Please sign in to comment.