-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add send to lightning address (#520)
* feat: add send to lightning address * chore: update csp in http_service * chore: refactor * chore: remove regexes * chore: pass lnurlpresponse in state * chore: remove comments * chore: avoid multiple calls to fetch * chore: rename Send folder * chore: get recipient from param * fix: rename send * fix: balance card * chore: change error message * chore: dry up lnurlpay and redirect if state is empty * chore: simplify numberformat usage * fix: amount formatting on confirm payment page * chore: ensure preimage in pay response * fix: unreliable multi pay invoice controller test * fix: unreliable multi pay invoice controller test * chore: remove recipient param --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
- Loading branch information
1 parent
4ab48ed
commit 7e8da27
Showing
14 changed files
with
449 additions
and
280 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { LucideIcon } from "lucide-react"; | ||
import { Link } from "react-router-dom"; | ||
import { Button } from "src/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "src/components/ui/card"; | ||
|
||
type BalanceCardProps = { | ||
title: string; | ||
balance: number; | ||
buttonTitle: string; | ||
buttonLink: string; | ||
hasChannelManagement: boolean; | ||
BalanceCardIcon: LucideIcon; | ||
}; | ||
|
||
function BalanceCard({ | ||
title, | ||
balance, | ||
buttonTitle, | ||
buttonLink, | ||
hasChannelManagement, | ||
BalanceCardIcon, | ||
}: BalanceCardProps) { | ||
return ( | ||
<Card className="w-full hidden md:block self-start"> | ||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> | ||
<CardTitle className="text-sm font-medium">{title}</CardTitle> | ||
<BalanceCardIcon className="h-4 w-4 text-muted-foreground" /> | ||
</CardHeader> | ||
<CardContent> | ||
<div className="text-2xl font-bold balance sensitive"> | ||
{new Intl.NumberFormat().format(Math.floor(balance / 1000))} sats | ||
</div> | ||
</CardContent> | ||
{hasChannelManagement && ( | ||
<CardFooter className="flex justify-end"> | ||
<Link to={buttonLink}> | ||
<Button variant="outline">{buttonTitle}</Button> | ||
</Link> | ||
</CardFooter> | ||
)} | ||
</Card> | ||
); | ||
} | ||
|
||
export default BalanceCard; |
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,41 @@ | ||
import { ArrowUp } from "lucide-react"; | ||
import { Outlet } from "react-router-dom"; | ||
import AppHeader from "src/components/AppHeader"; | ||
import BalanceCard from "src/components/BalanceCard"; | ||
import Loading from "src/components/Loading"; | ||
import { useBalances } from "src/hooks/useBalances"; | ||
import { useChannels } from "src/hooks/useChannels"; | ||
|
||
import { useInfo } from "src/hooks/useInfo"; | ||
|
||
export default function Send() { | ||
const { hasChannelManagement } = useInfo(); | ||
const { data: balances } = useBalances(); | ||
const { data: channels } = useChannels(); | ||
|
||
if (!balances || !channels) { | ||
return <Loading />; | ||
} | ||
|
||
return ( | ||
<div className="grid gap-5"> | ||
<AppHeader | ||
title="Send" | ||
description="Pay a lightning invoice created by any bitcoin lightning wallet" | ||
/> | ||
<div className="flex gap-12 w-full"> | ||
<div className="w-full max-w-lg"> | ||
<Outlet /> | ||
</div> | ||
<BalanceCard | ||
balance={balances.lightning.totalSpendable} | ||
title="Spending Balance" | ||
buttonTitle="Top Up" | ||
buttonLink="/channels/outgoing" | ||
BalanceCardIcon={ArrowUp} | ||
hasChannelManagement={!!hasChannelManagement} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
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.