Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
RskWallet.prototype.getAddressByPath = function(path) {
var self = this;
//bitcoin
var derivedPrimaryPublicKey = self.getPrimaryPublicKey(path);
console.log("btc derived key:",derivedPrimaryPublicKey);
//rsk
var derivedEthAddy = ethhdkey.fromExtendedKey(derivedPrimaryPublicKey.toBase58())
var address = derivedEthAddy.getWallet().getAddressString()
console.log("rsk addy: ",address)
return address
};
deriveChild (index, secPass) {
let w = this._wallet;
let cipher;
if (w.isDoubleEncrypted) {
if (!secPass) throw new Error('Second password required to derive ethereum wallet');
else cipher = w.createCipher(secPass);
}
let masterHdNode = w.hdwallet.getMasterHDNode(cipher);
let accountNode = masterHdNode
.deriveHardened(44)
.deriveHardened(60)
.deriveHardened(0)
.derive(0)
.derive(index);
return EthHd.fromExtendedKey(accountNode.toBase58());
}
const getHWDAddresses = (store, start) => {
const hdk = new HDKey()
hdk.publicKey = new Buffer(publicKey, 'hex')
hdk.chainCode = new Buffer(chainCode, 'hex')
const accounts = []
for (let i = start; i < start + increment; i++) {
const derivedKey = hdk.derive(`m/${i}`)
const address = ehdkey
.fromExtendedKey(derivedKey.publicExtendedKey)
.getWallet()
.getAddress()
.toString('hex')
const aPath = `${path}/${i}`
const aAddress = `0x${address}`
accounts.push({
path: aPath,
address: aAddress,
index: i,
})
addressMapping[aPath] = aAddress
store.dispatch(addTrackedAddress({ address: aAddress, tokenAddress: ETH_ADDRESS }))
}
store.dispatch({
type: 'LOADED_HDW_ACCOUNTS',
window.TrezorConnect.getXPubKey(basePath, response => {
if (response.success) {
trezorEthInstance.networkId = networkId;
trezorEthInstance.hdkey = HDKey.fromExtendedKey(response.xpubkey);
trezorEthInstance.basePath = basePath;
resolve(trezorEthInstance);
} else {
reject(response.error);
}
});
});
constructor (xPrivKey) {
this._hdKey = fromExtendedKey(xPrivKey)
this._root = this._hdKey.derivePath(BIP44_PATH)
this._children = []
}