trufflesuite / truffle-hdwallet-provider

HD Wallet-enabled Web3 provider
MIT License
399 stars 167 forks source link

HDWalletProvider ignores path #94

Closed ldub closed 5 years ago

ldub commented 5 years ago

In the following, I generate two HDWalletProviders with the same mnemonic and different paths, and HDWalletProvider generates the same address and private key.

$ cat package-lock.json | grep hdwallet-provider
    "truffle-hdwallet-provider": {
      "resolved": "https://registry.npmjs.org/truffle-hdwallet-provider/-/truffle-hdwallet-provider-0.0.6.tgz",

$ node
> let HDWalletProvider = require("truffle-hdwallet-provider");
undefined
> let mnemonic = "myth like bonus scare over problem client lizard pioneer submit female collect";
undefined
> new HDWalletProvider(mnemonic, null, address_index=0, num_addresses=1, wallet_hdpath="m/44'/60'/0'/0").addresses
[ '0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1' ]
> new HDWalletProvider(mnemonic, null, address_index=0, num_addresses=1, wallet_hdpath="m/44'/137'/0'/0").addresses
[ '0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1' ]
> new HDWalletProvider(mnemonic, null, address_index=0, num_addresses=1, wallet_hdpath="m/44'/60'/0'/0").hdwallet._hdkey._privateKey
<Buffer 11 9f 6f 1e 1a a1 3d ed 96 fd 67 0f 64 68 10 2a c3 8b 0a 5b 3b a3 9f f0 e7 23 0e 46 ea b3 2f 8a>
> new HDWalletProvider(mnemonic, null, address_index=0, num_addresses=1, wallet_hdpath="m/44'/137'/0'/0").hdwallet._hdkey._privateKey
<Buffer 11 9f 6f 1e 1a a1 3d ed 96 fd 67 0f 64 68 10 2a c3 8b 0a 5b 3b a3 9f f0 e7 23 0e 46 ea b3 2f 8a>
>
ldub commented 5 years ago

My bad... looks like path derivation was not supported in 0.0.6