View Source BitcoinLib.Key.HD.DerivationPath.Parser (BitcoinLib v0.2.0-pre3)

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

maybe_parse_valid_derivation_path(arg)

View Source
@spec maybe_parse_valid_derivation_path({:ok, binary()} | {:error, 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> {:ok, "m/44'/0'/0'/1/0"} ...> |> BitcoinLib.Key.HD.DerivationPath.Parser.maybe_parse_valid_derivation_path {

:ok,
%BitcoinLib.Key.HD.DerivationPath{
  type: :private,
  purpose: :bip44,
  coin_type: :bitcoin,
  account: %BitcoinLib.Key.HD.DerivationPath.Level{hardened?: true, value: 0},
  change: :change_chain,
  address_index: %BitcoinLib.Key.HD.DerivationPath.Level{hardened?: false, value: 0}
}

}