ConseilJS
ConseilJS copied to clipboard
Add HD wallet support
The TezosWallet module was written with the option of adding HD wallet support. The logic must now be extended to allow HD support to prepare for hardware wallet support.
- [ ] Incorporate BIP32 library for supporting derivation paths and refactor
getKeysFromMnemonicAndPassphrase()to explicitly use BIP32. - [ ] Split
getKeysFromMnemonicAndPassphrase()into two functions -getSeedFromMnemonicAndPassphrase()andgetKeysFromSeed() - [ ] 'getKeysFromMnemonicAndPassphrase()' should also take an optional derivation path argument.
- [ ] `getSeedFromMnemonicAndPassphrase()' should take as parameters - a fifteen or twenty-four word mnemonic, an optional passphrase, - and return a seed.
- [ ] 'getKeysFromSeed()' should take as parameters - a seed and a derivation path- and return a key store corresponding to the root account.*
- [ ] A new
getDerivedAddress()function should take as parameters - a seed, a derivation path and an index - and return a key store corresponding to a derived account. - [ ] A new
getAllActiveDerivedAddresses()function should take as parameters - a seed and a derivation path - and return all derived addresses which can be found on the Tezos blockchain.
HD wallet usage of the above:
- Ask user for a mnemonic
- Call
getKeysFromMnemonicAndPassphrase()with above to get the root address and seed. - Call
getAllActiveDerivedAddresses()with the above seed and a derivation path to get a list of all derived addresses. - To create a new derived address, call
getKeysFromSeed()with the above seed and the next index. - To load an existing wallet, fetch the seed of the root address from disk and then call
getAllActiveDerivedAddresses().
The Wallet interface currently supports an arbitrary number of KeyStores. Any client is free to add as many KeyStores, therefore as many seeds, to a wallet file as they want. However, in HD mode, we want a wallet file to contain no more than a single seed. Therefore, we must implement a new HDWallet interface which essentially inherits from Wallet but constrains the number of KeyStores to a maximum of one and the KeyStore object to contain a non-null seed.