- export function getSaveHDWalletAccounts (saveHDWallet, password, accountCount) {
- const walletKey = {
- secretKey: decryptKey(password, Buffer.from(saveHDWallet.secretKey, 'hex')),
- chainCode: decryptKey(password, Buffer.from(saveHDWallet.chainCode, 'hex'))
- }
- return (new Array(accountCount)).fill()
- .map((_, idx) =>
- formatAccount(getKeyPair(derivePathFromKey(`${idx}h/0h/0h`, walletKey).secretKey)))
- }
-
- export const getHdWalletAccountFromMnemonic = (mnemonic, accountIdx) => {
- const seed = mnemonicToSeed(mnemonic)
- const walletKey = derivePathFromSeed('m/44h/457h', seed)
- const derived = derivePathFromKey(`${accountIdx}h/0h/0h`, walletKey)
- const keyPair = getKeyPair(derived.secretKey)
- return {
- ...formatAccount(keyPair),
- idx: accountIdx
- }
- }
-