Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getLedgerAddresses (startingIndex, numAddresses, change = false) {
const walletPubKey = await this.getWalletPublicKey(this._baseDerivationPath)
const compressedPubKey = compressPubKey(walletPubKey.publicKey)
const node = bip32.fromPublicKey(
Buffer.from(compressedPubKey, 'hex'),
Buffer.from(walletPubKey.chainCode, 'hex'),
this._network
)
const addresses = []
const lastIndex = startingIndex + numAddresses
const changeVal = change ? '1' : '0'
for (let currentIndex = startingIndex; currentIndex < lastIndex; currentIndex++) {
const subPath = changeVal + '/' + currentIndex
const publicKey = node.derivePath(subPath).publicKey
const address = pubKeyToAddress(publicKey, this._network.name, 'pubKeyHash')
const path = this._baseDerivationPath + subPath