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.
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.
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.
getKeysFromMnemonicAndPassphrase()to explicitly use BIP32.getKeysFromMnemonicAndPassphrase()into two functions -getSeedFromMnemonicAndPassphrase()andgetKeysFromSeed()getDerivedAddress()function should take as parameters - a seed, a derivation path and an index - and return a key store corresponding to a derived account.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:
getKeysFromMnemonicAndPassphrase()with above to get the root address and seed.getAllActiveDerivedAddresses()with the above seed and a derivation path to get a list of all derived addresses.getKeysFromSeed()with the above seed and the next index.getAllActiveDerivedAddresses().The
Walletinterface 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 newHDWalletinterface which essentially inherits fromWalletbut constrains the number of KeyStores to a maximum of one and the KeyStore object to contain a non-null seed.