mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
add mneumonic phrase for cashu mode and rename MintModal file
This commit is contained in:
1 parent
3b8c5da1fd
commit
015e7b8b90
4 files changed
+303
-4
No files matched your search
@@ -12,11 +12,11 @@ import { useWalletTransactions } from '@/hooks/cashu/useWalletTransactions';
|
||||
import { useHistoryManager } from '@/hooks/cashu/useHistoryManager';
|
||||
import { useNsecAccess } from '@/hooks/useNsecAccess';
|
||||
import { useBitcoinBalance } from '@/hooks/useBitcoinBalance';
|
||||
import { nostrPubkeyToBitcoinAddress, npubToBitcoinAddress, fetchUTXOs, getFeeRates, createBitcoinTransaction, broadcastTransaction } from '@/lib/bitcoin';
|
||||
import { nostrPubkeyToBitcoinAddress, npubToBitcoinAddress, fetchUTXOs, getFeeRates, createBitcoinTransaction, broadcastTransaction, UTXO } from '@/lib/bitcoin';
|
||||
import { QRModal } from '@/components/ui/qr-modal';
|
||||
import { WalletHeader } from './WalletHeader';
|
||||
import { TransactionCard } from './PaymentCard';
|
||||
import { WalletModals } from './MintModals';
|
||||
import { WalletModals } from './WalletModals';
|
||||
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from '@/components/ui/drawer';
|
||||
import { TransactionHistory } from './TransactionHistory';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
@@ -36,6 +36,7 @@ export function CashuWallet() {
|
||||
error,
|
||||
balances,
|
||||
mints,
|
||||
mnemonic,
|
||||
getEncodedToken,
|
||||
refreshMints,
|
||||
} = useCashu();
|
||||
@@ -169,6 +170,12 @@ export function CashuWallet() {
|
||||
const [pendingBitcoinRecipient, setPendingBitcoinRecipient] = useState<string | null>(null);
|
||||
const [showBitcoinAddressQR, setShowBitcoinAddressQR] = useState(false);
|
||||
const [bitcoinAddressQRCode, setBitcoinAddressQRCode] = useState('');
|
||||
const [showSeedPhraseInfo, setShowSeedPhraseInfo] = useState(false);
|
||||
|
||||
// UTXO state
|
||||
const [utxos, setUtxos] = useState<UTXO[]>([]);
|
||||
const [utxoDropdownOpen, setUtxoDropdownOpen] = useState(false);
|
||||
const [isLoadingUtxos, setIsLoadingUtxos] = useState(false);
|
||||
|
||||
// Handle drawer close with state reset
|
||||
const handleSendDrawerClose = (open: boolean) => {
|
||||
@@ -296,6 +303,26 @@ export function CashuWallet() {
|
||||
}
|
||||
};
|
||||
|
||||
// Fetch UTXOs for Bitcoin mode
|
||||
const fetchBitcoinUtxos = async () => {
|
||||
if (!bitcoinAddress || mode !== 'bitcoin') return;
|
||||
|
||||
setIsLoadingUtxos(true);
|
||||
try {
|
||||
const fetchedUtxos = await fetchUTXOs(bitcoinAddress);
|
||||
setUtxos(fetchedUtxos);
|
||||
} catch (error) {
|
||||
console.error('Error fetching UTXOs:', error);
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "UTXO Error",
|
||||
description: "Failed to fetch Bitcoin UTXOs",
|
||||
});
|
||||
} finally {
|
||||
setIsLoadingUtxos(false);
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// COMPUTED VALUES
|
||||
// ============================================================================
|
||||
@@ -389,6 +416,19 @@ export function CashuWallet() {
|
||||
};
|
||||
}, [isNpubCashLoggedIn, coco, isInitialized, syncQuotesWithWallet, toast]);
|
||||
|
||||
// ============================================================================
|
||||
// EFFECTS - UTXO Fetching
|
||||
// ============================================================================
|
||||
|
||||
useEffect(() => {
|
||||
if (mode === 'bitcoin' && bitcoinAddress) {
|
||||
fetchBitcoinUtxos();
|
||||
} else {
|
||||
// Clear UTXOs when not in Bitcoin mode
|
||||
setUtxos([]);
|
||||
}
|
||||
}, [mode, bitcoinAddress]);
|
||||
|
||||
// ============================================================================
|
||||
// EFFECTS - Cleanup
|
||||
// ============================================================================
|
||||
@@ -420,6 +460,7 @@ export function CashuWallet() {
|
||||
setMode={setMode}
|
||||
userPubkey={user?.pubkey}
|
||||
npubCashUsername={user?.pubkey ? (npubCashUserInfo?.name || nip19.npubEncode(user.pubkey)) : undefined}
|
||||
mnemonic={mnemonic}
|
||||
onCopyToClipboard={copyToClipboard}
|
||||
onShowLightningAddressQR={(qr) => {
|
||||
setLightningAddressQRCode(qr);
|
||||
@@ -429,6 +470,7 @@ export function CashuWallet() {
|
||||
setBitcoinAddressQRCode(qr);
|
||||
setShowBitcoinAddressQR(true);
|
||||
}}
|
||||
onShowSeedPhraseInfo={() => setShowSeedPhraseInfo(true)}
|
||||
generateQRCode={generateQRCode}
|
||||
// MintSelector props
|
||||
activeMintUrl={activeMintUrl}
|
||||
@@ -442,6 +484,10 @@ export function CashuWallet() {
|
||||
getCleanMintLabel={getCleanMintLabel}
|
||||
dropdownOpen={mintDropdownOpen}
|
||||
setDropdownOpen={setMintDropdownOpen}
|
||||
// UTXOSelector props
|
||||
utxos={utxos}
|
||||
utxoDropdownOpen={utxoDropdownOpen}
|
||||
setUtxoDropdownOpen={setUtxoDropdownOpen}
|
||||
/>
|
||||
|
||||
|
||||
@@ -504,6 +550,8 @@ export function CashuWallet() {
|
||||
sentToken={sentToken}
|
||||
setSentToken={setSentToken}
|
||||
sentTokenQRCode={sentTokenQRCode}
|
||||
showSeedPhraseInfo={showSeedPhraseInfo}
|
||||
setShowSeedPhraseInfo={setShowSeedPhraseInfo}
|
||||
/>
|
||||
|
||||
{/* Bottom Drawer Modals */}
|
||||
|
||||
Reference in new issue
Block a user