fix consolidate utxo modal infinite rerender loop

This commit is contained in:
lemonknowsall committed 2025-11-03 13:25:20 -08:00
1 parent 6fc1df5538
commit e0031c6b14
1 file changed
+4 -4
+4 -4
View File
@@ -1,8 +1,8 @@
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { useState } from 'react'; import { useState, useCallback } from 'react';
import { fetchUTXOs, getFeeRates, createBitcoinTransaction, broadcastTransaction, calculateMaxSendAmount, npubToBitcoinAddress, nostrPubkeyToBitcoinAddress, type UTXO } from '@/lib/bitcoin'; import { fetchUTXOs, getFeeRates, createBitcoinTransaction, broadcastTransaction, calculateMaxSendAmount, npubToBitcoinAddress, nostrPubkeyToBitcoinAddress, type UTXO } from '@/lib/bitcoin';
import type { BitcoinTransaction } from '@/components/wallet/TransactionHistory'; import type { BitcoinTransaction } from '@/components/wallet/TransactionHistory';
import { useToast } from '@/hooks/useToast'; import { useToast, toast } from '@/hooks/useToast';
import { useQRCode } from '@/hooks/wallet/useQRCode'; import { useQRCode } from '@/hooks/wallet/useQRCode';
import { useNsecAccess } from '@/hooks/useNsecAccess'; import { useNsecAccess } from '@/hooks/useNsecAccess';
@@ -156,7 +156,7 @@ export function useBitcoinOperations(bitcoinAddress: string | null) {
const bitcoinMaxAmount = utxos.length > 0 ? calculateMaxSendAmount(utxos, feeRate) : 0; const bitcoinMaxAmount = utxos.length > 0 ? calculateMaxSendAmount(utxos, feeRate) : 0;
// Fetch UTXOs for Bitcoin mode // Fetch UTXOs for Bitcoin mode
const fetchBitcoinUtxos = async () => { const fetchBitcoinUtxos = useCallback(async () => {
if (!bitcoinAddress) return; if (!bitcoinAddress) return;
setIsLoadingUtxos(true); setIsLoadingUtxos(true);
@@ -177,7 +177,7 @@ export function useBitcoinOperations(bitcoinAddress: string | null) {
} finally { } finally {
setIsLoadingUtxos(false); setIsLoadingUtxos(false);
} }
}; }, [bitcoinAddress]);
// Handle Send Max // Handle Send Max
const handleSendMax = (setBitcoinAmount: (amount: string) => void) => { const handleSendMax = (setBitcoinAmount: (amount: string) => void) => {