View Source BitcoinLib.Key.HD.DerivationPath.Parser (BitcoinLib v0.4.1)

Single purpose module that aims to simplify DerivationPath by isolating string parsing business logic

Link to this section Summary

Functions

Single purpose function that's being called by DerivationPath.parse/1, returning a DerivationPath out of a string if the tuple starts by :ok

Link to this section Functions

Link to this function

parse_valid_derivation_path(derivation_path)

View Source
@spec parse_valid_derivation_path(binary()) ::
  {:ok,
   %BitcoinLib.Key.HD.DerivationPath{
     account: term(),
     address_index: term(),
     change: term(),
     coin_type: term(),
     purpose: term(),
     type: term()
   }}
  | {:error, binary()}

Single purpose function that's being called by DerivationPath.parse/1, returning a DerivationPath out of a string if the tuple starts by :ok

examples

Examples

iex> "m/44'/0'/0'/1/0"
...> |> BitcoinLib.Key.HD.DerivationPath.Parser.parse_valid_derivation_path
{
  :ok,
  %BitcoinLib.Key.HD.DerivationPath{
    type: :private,
    purpose: :bip44,
    coin_type: :bitcoin,
    account: 0,
    change: :change_chain,
    address_index: 0
  }
}