import React from 'react'; import { Box, Text } from 'ink'; import { colors, formatSatoshis, formatHex } from '../../../theme.js'; import { useSatoshisConversion } from '../../../hooks/useSatoshisConversion.js'; import type { SelectableUTXO, FocusArea } from '../types.js'; interface Props { availableUtxos: SelectableUTXO[]; selectedUtxoIndex: number; requiredAmount: bigint; fee: bigint; selectedAmount: bigint; changeAmount: bigint; focusArea: FocusArea; } export function InputsStep({ availableUtxos, selectedUtxoIndex, requiredAmount, fee, selectedAmount, changeAmount, focusArea, }: Props): React.ReactElement { const { formatSatoshisToFiat } = useSatoshisConversion(); const getFiatSuffix = (satoshis: bigint): string => { const fiatValue = formatSatoshisToFiat(satoshis); return fiatValue ? ` (~${fiatValue})` : ''; }; return ( Select UTXOs to fund the transaction: Required: {formatSatoshis(requiredAmount)} +{' '} {formatSatoshis(fee)} fee {getFiatSuffix(requiredAmount + fee)} = requiredAmount + fee ? colors.success : colors.warning } > Selected: {formatSatoshis(selectedAmount)} {getFiatSuffix(selectedAmount)} {selectedAmount > requiredAmount + fee && ( Change: {formatSatoshis(changeAmount)} {getFiatSuffix(changeAmount)} )} {availableUtxos.length === 0 ? ( No UTXOs available ) : ( availableUtxos.map((utxo, index) => { const isCursor = selectedUtxoIndex === index && focusArea === 'content'; return ( {isCursor ? '▸ ' : ' '}[{utxo.selected ? 'X' : ' '}]{' '} {formatSatoshis(utxo.valueSatoshis)} -{' '} {formatHex(utxo.outpointTransactionHash, 12)}: {utxo.outpointIndex} {(() => { const fiatValue = formatSatoshisToFiat(utxo.valueSatoshis); if (!fiatValue) return null; return ( {' '}≈ {fiatValue} ); })()} ); }) )} Space/Enter: Toggle • a: Select all • n: Deselect all ); }