Tradehub.ExtendedKey.derive_path

You're seeing just the function derive_path, go back to Tradehub.ExtendedKey module for more information.
Link to this function

derive_path(master, path)

View Source

Specs

derive_path(master :: key(), path :: String.t()) :: key() | {:error, term()}

Derives child extended key with given key path, hardened can be represented with H, h or ', e.g. m/0H/1/2H/2/1000000000

Examples

Derive private extended key

iex> seed = Base.decode16!("81D0E7581BF0C55B2941B2295EB4FD1F9C52D080F8D58A3DB634DE80200BA238")
iex> master = ExtendedKey.master(seed)
iex> ExtendedKey.derive_path(master, "m/0")
%ExtendedKey{
  chain_code: <<81, 134, 58, 230, 254, 116, 95, 133, 120,
    201, 148, 202, 21, 162, 172, 251, 172, 207, 11, 123, 23,
    163, 17, 104, 229, 164, 4, 203, 82, 235, 182, 98>>,
  child_num: 0,
  depth: 1,
  key: <<221, 183, 68, 24, 208, 227, 114, 203, 222, 172, 41,
    97, 113, 120, 208, 123, 220, 241, 248, 18, 174, 129, 46,
    20, 141, 240, 111, 137, 78, 163, 176, 38>>,
  parent_fingerprint: <<197, 217, 101, 7>>,
  version: <<4, 136, 173, 228>>
}

Derives public extended key

iex> seed = Base.decode16!("81D0E7581BF0C55B2941B2295EB4FD1F9C52D080F8D58A3DB634DE80200BA238")
iex> master = ExtendedKey.master(seed)
iex> ExtendedKey.derive_path(master, "M/0")
%ExtendedKey{
  chain_code: <<81, 134, 58, 230, 254, 116, 95, 133, 120,
    201, 148, 202, 21, 162, 172, 251, 172, 207, 11, 123, 23,
    163, 17, 104, 229, 164, 4, 203, 82, 235, 182, 98>>,
  child_num: 0,
  depth: 1,
  key: <<3, 105, 136, 100, 17, 127, 136, 122, 182, 104, 212,
    103, 97, 101, 215, 37, 57, 133, 58, 22, 120, 242, 32,
    192, 179, 205, 202, 61, 143, 32, 166, 96, 204>>,
  parent_fingerprint: <<197, 217, 101, 7>>,
  version: <<4, 136, 178, 30>>
}