Open shayanb opened 7 years ago
@shayanb Right now we don't really support iterations beyond HdPathString/i
where i
is an integer 0, 1, 2, ...
.
You say you want to generate
Address 1= m'/0'/0'/1
Address 2= m'/0'/0'/2
Address 3= m'/0'/0'/3
and this is very easy to do by using m'/0'/0'
as hdPathString
and then you can do
ks.generateNewAddress(pwDerivedKey, 4)
to generate m'/0'/0'/0
as well as the 3 addresses in your example.
@christianlundkvist Thanks, the way ks.generateNewAddress(pwDerivedKey, 4)
works is that if you generate 4 for now and later on you want to continue on the path using another instance of the app, you have to generate let's say 10 and don't use the first 4 that you've already used. This solution would not be really scalable.
I made a pull request to add this feature so you can derive any path you need: https://github.com/ConsenSys/eth-lightwallet/pull/156
keystore.generateNewAddressOnPath(pwDerivedKey, [hdPathString], [index])
Please take a look and merge.
I'm trying to use eth-lightwallet to generate BIP32/44 style addresses using custom paths, let's say:
The way eth-lightwallet seems to be working is by using
ks.generateNewAddress(pwDerivedKey, 1);
you'd get the next address but I couldn't find a way to get either the path for that address or input the custom path to generate the address in the path I want.There's a way to iterate through the addresses which is a bit hacky, something like the following:
Here is the source code for such iteration:
The ^ solution is using the deprecated function which will be removed on next updates.
However using the new method
KeyStore.createVault()
even this hack is not possible as it would throw exception.this works fine when the finalHdPath is
m/0'/0'/0'
. but fails as soon as we try to run it using any other default path:for input
m/0'/0'/0'
:for input
m/0'/0'/1'
: