Skip to content

Commit

Permalink
fix: do not change deposit address after depositing funds on current …
Browse files Browse the repository at this point in the history
…channel order page
  • Loading branch information
rolznz committed Jul 26, 2024
1 parent 45600ee commit c6bc381
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions frontend/src/hooks/useOnchainAddress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import useSWR from "swr";
import useSWRImmutable from "swr/immutable";

import React from "react";
import { useCSRF } from "src/hooks/useCSRF";
Expand All @@ -7,7 +7,10 @@ import { swrFetcher } from "src/utils/swr";

export function useOnchainAddress() {
const { data: csrf } = useCSRF();
const swr = useSWR<string>("/api/wallet/address", swrFetcher);
// Use useSWRImmutable to avoid address randomly changing after deposit (e.g. on page re-focus on the channel order page)
const swr = useSWRImmutable<string>("/api/wallet/address", swrFetcher, {
revalidateOnMount: true,
});
const [isLoading, setLoading] = React.useState(false);

const getNewAddress = React.useCallback(async () => {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/screens/channels/CurrentChannelOrder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ function PayBitcoinChannelOrderTopup({ order }: { order: NewChannelOrder }) {
</CardDescription>
</CardHeader>
{unspentAmount > 0 && (
<CardContent>{unspentAmount} sats deposited</CardContent>
<CardContent>
{new Intl.NumberFormat().format(unspentAmount)} sats deposited
</CardContent>
)}
</Card>

Expand Down

0 comments on commit c6bc381

Please sign in to comment.