-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: pay 0-amount invoices * chore: update lightning-tools dependency * feat: pay 0 amount invoices in LND * chore: typo * fix: lightning-tools dependency version --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
- Loading branch information
1 parent
2d1327e
commit 044e0c3
Showing
26 changed files
with
309 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React from "react"; | ||
import { Button } from "src/components/ui/button"; | ||
import { Input } from "src/components/ui/input"; | ||
import { Label } from "src/components/ui/label"; | ||
import { LoadingButton } from "src/components/ui/loading-button"; | ||
import { useToast } from "src/components/ui/use-toast"; | ||
|
||
import { Invoice } from "@getalby/lightning-tools"; | ||
import { Link, useLocation, useNavigate } from "react-router-dom"; | ||
import Loading from "src/components/Loading"; | ||
|
||
export default function ZeroAmount() { | ||
const { state } = useLocation(); | ||
const navigate = useNavigate(); | ||
const { toast } = useToast(); | ||
|
||
const paymentRequest = state?.args?.paymentRequest as Invoice; | ||
const [amount, setAmount] = React.useState(""); | ||
const [isLoading, setLoading] = React.useState(false); | ||
|
||
const onSubmit = async (event: React.FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
try { | ||
if (!paymentRequest) { | ||
throw new Error("no invoice set"); | ||
} | ||
setLoading(true); | ||
|
||
navigate(`/wallet/send/confirm-payment`, { | ||
state: { | ||
args: { paymentRequest, amount: parseInt(amount) }, | ||
}, | ||
}); | ||
} catch (e) { | ||
toast({ | ||
variant: "destructive", | ||
title: "Failed to send payment", | ||
description: "" + e, | ||
}); | ||
console.error(e); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
React.useEffect(() => { | ||
if (!paymentRequest) { | ||
navigate("/wallet/send"); | ||
} | ||
}, [navigate, paymentRequest]); | ||
|
||
if (!paymentRequest) { | ||
return <Loading />; | ||
} | ||
|
||
return ( | ||
<form onSubmit={onSubmit} className="grid gap-4"> | ||
<div> | ||
{paymentRequest.description && ( | ||
<div className="mt-2"> | ||
<Label>Description</Label> | ||
<p className="text-muted-foreground"> | ||
{paymentRequest.description} | ||
</p> | ||
</div> | ||
)} | ||
<div className="mb-2"> | ||
<Label htmlFor="amount">Amount</Label> | ||
<Input | ||
id="amount" | ||
type="number" | ||
value={amount} | ||
placeholder="Amount in Satoshi..." | ||
onChange={(e) => { | ||
setAmount(e.target.value.trim()); | ||
}} | ||
min={1} | ||
required | ||
autoFocus | ||
/> | ||
</div> | ||
</div> | ||
<div className="flex gap-4"> | ||
<LoadingButton loading={isLoading} type="submit"> | ||
Continue | ||
</LoadingButton> | ||
<Link to="/wallet/send"> | ||
<Button variant="secondary">Back</Button> | ||
</Link> | ||
</div> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.