Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import { P2Ret } from '@scure/btc-signer/payment'; import { useConfigBitcoinEnabled } from '@app/query/common/remote-config/remote-config.query'; import { useCurrentAccountIndex } from '@app/store/accounts/account'; import { Signer } from '@app/store/accounts/blockchain/bitcoin/bitcoin-signer'; import { useNativeSegwitSigner } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; import { useTaprootSigner } from '@app/store/accounts/blockchain/bitcoin/taproot-account.hooks'; import { useCurrentNetwork } from '@app/store/networks/networks.selectors'; interface BitcoinAccountLoaderBaseProps { children(account: Signer<P2Ret>): React.ReactNode; fallback?: React.ReactNode; } interface BtcAccountLoaderCurrentProps extends BitcoinAccountLoaderBaseProps { current: true; } interface BtcAccountLoaderIndexProps extends BitcoinAccountLoaderBaseProps { index: number; } type BtcAccountLoaderProps = BtcAccountLoaderCurrentProps | BtcAccountLoaderIndexProps; export function BitcoinNativeSegwitAccountLoader({ children, fallback, ...props }: BtcAccountLoaderProps) { const isBitcoinEnabled = useConfigBitcoinEnabled(); const currentAccountIndex = useCurrentAccountIndex(); const properIndex = 'current' in props ? currentAccountIndex : props.index; const signer = useNativeSegwitSigner(properIndex); if (!signer || !isBitcoinEnabled) return fallback; return children(signer(0)); } export function BitcoinTaprootAccountLoader({ children, ...props }: BtcAccountLoaderProps) { const isBitcoinEnabled = useConfigBitcoinEnabled(); const network = useCurrentNetwork(); const currentAccountIndex = useCurrentAccountIndex(); const properIndex = 'current' in props ? currentAccountIndex : props.index; const signer = useTaprootSigner(properIndex, network.chain.bitcoin.mode); if (!signer || !isBitcoinEnabled) return null; return children(signer(0)); } |