fixed send card for on-chain and added pay to pubkey

This commit is contained in:
lemonknowsall committed 2025-10-19 21:54:27 -07:00
1 parent 617edd1784
commit 722b1a743f
7 files changed
+731 -40

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import { useQuery } from '@tanstack/react-query';
import { fetchUTXOs, type UTXO } from '@/lib/bitcoin';
/**
* Hook to fetch and manage Bitcoin balance from UTXOs
*/
export function useBitcoinBalance(address: string | null) {
return useQuery({
queryKey: ['bitcoin-balance', address],
queryFn: async (): Promise<{ balance: number; utxos: UTXO[] }> => {
if (!address) {
return { balance: 0, utxos: [] };
}
const utxos = await fetchUTXOs(address);
const balance = utxos.reduce((sum, utxo) => sum + utxo.value, 0);
return { balance, utxos };
},
enabled: !!address,
refetchInterval: 30000, // Refetch every 30 seconds
staleTime: 10000, // Consider data stale after 10 seconds
});
}