@exodus/key-utils
管理引出路径和关键识别特征的公用事业.
使用量
assertKeyIdentifierParameters 可用于验证 getKeyIdentifer
提供了正确的论据.
import { assertKeyIdentifierParameters } from '@exodus/key-utils'
export function createGetKeyIdentifier({
bip44,
assetName,
derivationAlgorithm = 'BIP32',
keyType = 'secp256k1',
}) {
return (params = {}) => {
params = { accountIndex: 0, addressIndex: 0, chainIndex: 0, ...params }
assertKeyIdentifierParameters(params)
// ...
}
}
这个图书馆也有 getKeyIdentifier (a) 工厂,这是可配置的,应能满足大多数资产需要:
const getKeyIdentifier = createGetKeyIdentifier({
bip44: assets.solana.bip44,
validationRules: { allowedChainIndices: [0, 1] },
})
// or for assets that support purpose 84, 86 as well
const getKeyIdentifier = createGetKeyIdentifier({
bip44: assets.bitcoin.bip44,
validationRules: { allowedChainIndices: [0, 1], allowedPurposes: [44, 84, 86] },
})