MCPcopy
hub / github.com/BlueWallet/BlueWallet / CoinControlOutputSheet

Function CoinControlOutputSheet

screen/send/CoinControlOutputSheet.tsx:24–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22type NavigationProps = NativeStackNavigationProp<SendDetailsStackParamList, 'CoinControlOutput'>;
23
24const CoinControlOutputSheet: React.FC = () => {
25 const navigation = useExtendedNavigation<NavigationProps>();
26 const route = useRoute<RouteProps>();
27 const { walletID, utxo } = route.params;
28 const { wallets, txMetadata, saveToDisk } = useStorage();
29 const wallet = useMemo(() => wallets.find(w => w.getID() === walletID), [walletID, wallets]);
30 const { colors } = useTheme();
31 const { isVisible } = useKeyboard();
32
33 const [memo, setMemo] = useState<string>('');
34 const [frozen, setFrozen] = useState<boolean>(false);
35 const [loading, setLoading] = useState<boolean>(true);
36
37 useEffect(() => {
38 if (!wallet) return;
39 const meta = wallet.getUTXOMetadata(utxo.txid, utxo.vout);
40 setMemo(meta.memo || txMetadata[utxo.txid]?.memo || '');
41 setFrozen(Boolean(meta.frozen));
42 setLoading(false);
43 }, [txMetadata, utxo.txid, utxo.vout, wallet]);
44
45 const switchValue = useMemo(
46 () => ({
47 value: frozen,
48 testID: 'FreezeSwitch',
49 onValueChange: async (value: boolean) => {
50 if (!wallet) return;
51 setFrozen(value);
52 wallet.setUTXOMetadata(utxo.txid, utxo.vout, { frozen: value });
53 await saveToDisk();
54 },
55 }),
56 [frozen, saveToDisk, utxo.txid, utxo.vout, wallet],
57 );
58
59 const onMemoChange = (value: string) => setMemo(value);
60
61 const debouncedSaveMemo = useRef(
62 debounce(async m => {
63 if (!wallet) return;
64 wallet.setUTXOMetadata(utxo.txid, utxo.vout, { memo: m });
65 await saveToDisk();
66 }, 500),
67 );
68
69 useEffect(() => {
70 debouncedSaveMemo.current(memo);
71 }, [memo]);
72
73 const amount = formatBalance(utxo.value, wallet?.getPreferredBalanceUnit?.() ?? BitcoinUnit.BTC, true);
74 const color = `#${utxo.txid.substring(0, 6)}`;
75 const confirmationsFormatted = useMemo(
76 () => new Intl.NumberFormat(RNLocalize.getLocales()[0].languageCode, { maximumSignificantDigits: 3 }).format(utxo.confirmations ?? 0),
77 [utxo.confirmations],
78 );
79
80 const handleUseCoin = useCallback(async () => {
81 if (!wallet) return;

Callers

nothing calls this directly

Calls 11

useExtendedNavigationFunction · 0.90
useStorageFunction · 0.90
useThemeFunction · 0.90
useKeyboardFunction · 0.90
formatBalanceFunction · 0.90
debounceFunction · 0.85
getIDMethod · 0.45
getUTXOMetadataMethod · 0.45
setUTXOMetadataMethod · 0.45

Tested by

no test coverage detected