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 | import { useCallback } from 'react';
import StacksApp from '@zondax/ledger-stacks';
import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks';
import { requestPublicKeyForStxAccount } from '../utils/stacks-ledger-utils';
import { useLedgerNavigate } from './use-ledger-navigate';
export function useVerifyMatchingLedgerStacksPublicKey() {
const account = useCurrentStacksAccount();
const ledgerNavigate = useLedgerNavigate();
return useCallback(
async (stacksApp: StacksApp) => {
if (!account) return;
const { publicKey } = await requestPublicKeyForStxAccount(stacksApp)(account.index);
if (publicKey.toString('hex') !== account.stxPublicKey) {
ledgerNavigate.toPublicKeyMismatchStep();
throw new Error('Mismatching public keys');
}
},
[account, ledgerNavigate]
);
}
|