diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2022-01-09 20:48:49 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2022-01-09 20:48:49 +0100 |
| commit | 7988f75774317d3ab0fdc513df12ccc77ef0d315 (patch) | |
| tree | ddfe932803cde7289d553b46691455d491dfe1ae /src/hdk.rs | |
| parent | a51adad4672c443ebeb6c427ab37ba6c5694ecd8 (diff) | |
expose derive_index
Diffstat (limited to 'src/hdk.rs')
| -rw-r--r-- | src/hdk.rs | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -12,6 +12,12 @@ use sha2::Sha512; /// A value indicating a path component is hardened. const HARDENED: u32 = 0x8000_0000; +/// Creates a new extended private key for an account index using the standard +/// Ethereum HD path. +pub fn derive_index(seed: impl AsRef<[u8]>, account_index: usize) -> Result<PrivateKey> { + derive(seed, &format!("m/44'/60'/0'/0/{}", account_index).parse()?) +} + /// Creates a new extended private key from a seed. pub fn derive(seed: impl AsRef<[u8]>, path: &Path) -> Result<PrivateKey> { derive_slice(seed.as_ref(), path) |
