From 494782170057a96d4ea2ea2efc25fc54e31969b0 Mon Sep 17 00:00:00 2001 From: Parth Bandwal <143504541+parrth20@users.noreply.github.com> Date: Tue, 28 Jul 2026 19:56:33 +0530 Subject: [PATCH 1/2] fix(receive): block new addresses during rescan --- src/components/receive/ReceivePage.test.tsx | 18 ++++++++++++++++++ src/components/receive/ReceivePage.tsx | 11 +++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/receive/ReceivePage.test.tsx b/src/components/receive/ReceivePage.test.tsx index b355513e2..236d659b3 100644 --- a/src/components/receive/ReceivePage.test.tsx +++ b/src/components/receive/ReceivePage.test.tsx @@ -34,6 +34,7 @@ const mocks = vi.hoisted(() => { return { developerMode: false, + rescanning: false, getAddress: vi.fn(), defaultJars, jars: defaultJars, @@ -107,6 +108,12 @@ vi.mock('@/context/JamWalletInfoContext', () => ({ }), })) +vi.mock('@/context/JamSessionInfoContext', () => ({ + useRescanStatus: () => ({ + rescanInfo: { rescanning: mocks.rescanning }, + }), +})) + vi.mock('@/hooks/useApiClient', () => ({ useApiClient: () => ({}), })) @@ -148,6 +155,7 @@ vi.mock('./ReceiveForm', () => ({ describe('ReceivePage', () => { beforeEach(() => { mocks.developerMode = false + mocks.rescanning = false mocks.jars = mocks.defaultJars mocks.getAddress.mockReset() mocks.getAddress.mockResolvedValue({ data: { address: 'bc1qexample' } }) @@ -175,6 +183,16 @@ describe('ReceivePage', () => { await flushActUpdates() }) + it('prevents loading addresses while rescanning', () => { + mocks.rescanning = true + + render() + + expect(screen.getByRole('button', { name: 'receive.button_reveal_address' })).toBeDisabled() + expect(screen.getByRole('button', { name: 'receive.button_new_address' })).toBeDisabled() + expect(mocks.getAddress).not.toHaveBeenCalled() + }) + it('uses a secondary jar badge when no jar is available', () => { mocks.jars = [] diff --git a/src/components/receive/ReceivePage.tsx b/src/components/receive/ReceivePage.tsx index 9975902e4..6594c9910 100644 --- a/src/components/receive/ReceivePage.tsx +++ b/src/components/receive/ReceivePage.tsx @@ -10,6 +10,7 @@ import { Button } from '@/components/ui/button' import { Card, CardContent } from '@/components/ui/card' import PageTitle from '@/components/ui/jam/PageTitle' import { Skeleton } from '@/components/ui/skeleton' +import { useRescanStatus } from '@/context/JamSessionInfoContext' import { useJars } from '@/context/JamWalletInfoContext' import { useApiClient } from '@/hooks/useApiClient' import { withMutationDelay } from '@/lib/queryClient' @@ -34,6 +35,7 @@ interface ReceivePageProps { export const ReceivePage = ({ walletFileName }: ReceivePageProps) => { const { t } = useTranslation() const { jars } = useJars() + const { rescanInfo } = useRescanStatus() const [selectedSourceJarIndex, setSelectedSourceJarIndex] = useState(jars.length > 0 ? jars[0].jarIndex : undefined) const [amount, setAmount] = useState() @@ -107,6 +109,7 @@ export const ReceivePage = ({ walletFileName }: ReceivePageProps) => { } const fetchNewAddress = async () => { + if (rescanInfo.rescanning) return await getAddressMutation.mutateAsync() } @@ -132,7 +135,7 @@ export const ReceivePage = ({ walletFileName }: ReceivePageProps) => { variant={jarButtonVariant(selectedSourceJarIndex)} size="lg" onClick={() => void fetchNewAddress()} - disabled={getAddressMutation.isPending} + disabled={getAddressMutation.isPending || rescanInfo.rescanning} > {t('receive.button_reveal_address')} @@ -189,7 +192,11 @@ export const ReceivePage = ({ walletFileName }: ReceivePageProps) => {
-