diff --git a/app/(app)/send/0-amount.js b/app/(app)/send/0-amount.js
new file mode 100644
index 0000000..3b28dc7
--- /dev/null
+++ b/app/(app)/send/0-amount.js
@@ -0,0 +1,5 @@
+import { ZeroAmount } from "../../../pages/send/ZeroAmount";
+
+export default function Page() {
+ return ;
+}
diff --git a/package.json b/package.json
index d736de3..2ebec16 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
"test:ci": "jest"
},
"dependencies": {
- "@getalby/lightning-tools": "^5.1.1",
+ "@getalby/lightning-tools": "^5.1.2",
"@getalby/sdk": "^3.8.2",
"@popicons/react-native": "^0.0.20",
"@react-native-async-storage/async-storage": "1.23.1",
diff --git a/pages/send/ConfirmPayment.tsx b/pages/send/ConfirmPayment.tsx
index 25230fc..836704b 100644
--- a/pages/send/ConfirmPayment.tsx
+++ b/pages/send/ConfirmPayment.tsx
@@ -18,17 +18,22 @@ import { useAppStore } from "~/lib/state/appStore";
export function ConfirmPayment() {
const { data: transactions } = useTransactions();
- const { invoice, originalText, comment, successAction } =
+ const { invoice, originalText, comment, successAction, amount } =
useLocalSearchParams() as {
invoice: string;
originalText: string;
comment: string;
successAction: string;
+ amount?: string;
};
const getFiatAmount = useGetFiatAmount();
const [isLoading, setLoading] = React.useState(false);
const wallets = useAppStore((store) => store.wallets);
const selectedWalletId = useAppStore((store) => store.selectedWalletId);
+ const decodedInvoice = new Invoice({
+ pr: invoice,
+ });
+ const amountToPaySats = amount ? +amount : decodedInvoice.satoshi;
async function pay() {
setLoading(true);
@@ -39,6 +44,7 @@ export function ConfirmPayment() {
}
const response = await nwcClient.payInvoice({
invoice,
+ amount: amount ? amountToPaySats * 1000 : undefined,
});
console.info("payInvoice Response", response);
@@ -54,7 +60,7 @@ export function ConfirmPayment() {
preimage: response.preimage,
originalText,
invoice,
- amount: decodedInvoice.satoshi,
+ amount: amountToPaySats,
successAction,
},
});
@@ -65,9 +71,6 @@ export function ConfirmPayment() {
setLoading(false);
}
- const decodedInvoice = new Invoice({
- pr: invoice,
- });
return (
<>
@@ -75,9 +78,7 @@ export function ConfirmPayment() {
- {new Intl.NumberFormat().format(
- Math.ceil(decodedInvoice.satoshi),
- )}
+ {new Intl.NumberFormat().format(Math.ceil(amountToPaySats))}
sats
@@ -85,7 +86,7 @@ export function ConfirmPayment() {
{getFiatAmount && (
- {getFiatAmount(decodedInvoice.satoshi)}
+ {getFiatAmount(amountToPaySats)}
)}
diff --git a/pages/send/Send.tsx b/pages/send/Send.tsx
index 36bf59c..c83b48a 100644
--- a/pages/send/Send.tsx
+++ b/pages/send/Send.tsx
@@ -132,7 +132,20 @@ export function Send() {
return true;
} else {
// Check if this is a valid invoice
- new Invoice({ pr: text });
+ const invoice = new Invoice({ pr: text });
+
+ if (invoice.satoshi === 0) {
+ router.replace({
+ pathname: "/send/0-amount",
+ params: {
+ invoice: text,
+ originalText,
+ comment: invoice.description,
+ },
+ });
+ return true;
+ }
+
router.replace({
pathname: "/send/confirm",
params: { invoice: text, originalText },
diff --git a/pages/send/ZeroAmount.tsx b/pages/send/ZeroAmount.tsx
new file mode 100644
index 0000000..e7a03e7
--- /dev/null
+++ b/pages/send/ZeroAmount.tsx
@@ -0,0 +1,83 @@
+import { router, useLocalSearchParams } from "expo-router";
+import React from "react";
+import { View } from "react-native";
+import DismissableKeyboardView from "~/components/DismissableKeyboardView";
+import { DualCurrencyInput } from "~/components/DualCurrencyInput";
+import Loading from "~/components/Loading";
+import { Receiver } from "~/components/Receiver";
+import Screen from "~/components/Screen";
+import { Button } from "~/components/ui/button";
+import { Text } from "~/components/ui/text";
+import { errorToast } from "~/lib/errorToast";
+
+export function ZeroAmount() {
+ const { invoice, originalText, comment } =
+ useLocalSearchParams() as unknown as {
+ invoice: string;
+ originalText: string;
+ comment: string;
+ };
+ const [isLoading, setLoading] = React.useState(false);
+ const [amount, setAmount] = React.useState("");
+
+ async function submit() {
+ setLoading(true);
+ try {
+ router.push({
+ pathname: "/send/confirm",
+ params: {
+ invoice,
+ originalText,
+ amount,
+ },
+ });
+ } catch (error) {
+ console.error(error);
+ errorToast(error);
+ }
+ setLoading(false);
+ }
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+ {comment && (
+
+
+ Comment
+
+
+ {comment}
+
+
+ )}
+
+
+
+
+
+
+
+ >
+ );
+}
diff --git a/yarn.lock b/yarn.lock
index f417716..39ed398 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1247,10 +1247,10 @@
find-up "^5.0.0"
js-yaml "^4.1.0"
-"@getalby/lightning-tools@^5.1.1":
- version "5.1.1"
- resolved "https://registry.yarnpkg.com/@getalby/lightning-tools/-/lightning-tools-5.1.1.tgz#51125b2c58ef9372ae9efa93d0808d2205914b91"
- integrity sha512-qiGWY7AMnQXywNlpEUTm/2u7Qx0C0qV0i3vlAV5ip8xV2quo4hkesHuAh6dBg/p3VC7t1fa9YUe9677hvQ3fVA==
+"@getalby/lightning-tools@^5.1.2":
+ version "5.1.2"
+ resolved "https://registry.yarnpkg.com/@getalby/lightning-tools/-/lightning-tools-5.1.2.tgz#8a018e98d5c13097dd98d93192cf5e4e455f4c20"
+ integrity sha512-BwGm8eGbPh59BVa1gI5yJMantBl/Fdps6X4p1ZACnmxz9vDINX8/3aFoOnDlF7yyA2boXWCsReVQSr26Q2yjiQ==
"@getalby/sdk@^3.8.2":
version "3.8.2"