BSV-ex v0.2.0 BSV.Extended.PrivateKey View Source

BIP-32 extended private key module.

Link to this section Summary

Types

t()

Extended Private Key

Functions

Converts the given BIP39 seed to an extended private key.

Converts the given xprv string to an extended private key.

Returns the extended public key from the given extended private key.

Converts the given extended private key struct to an encoded xprv string.

Link to this section Types

Link to this type

t()

View Source
t() :: %BSV.Extended.PrivateKey{
  chain_code: binary(),
  child_number: integer(),
  depth: integer(),
  fingerprint: binary(),
  key: binary(),
  network: atom(),
  version_number: binary()
}

Extended Private Key

Link to this section Functions

Link to this function

from_seed(seed, options \\ [])

View Source

Converts the given BIP39 seed to an extended private key.

Options

The accepted options are:

  • :encoding - Optionally decode the given seed with either the :base64 or :hex encoding scheme.
  • :network - Specify the intended network. Defaults to :main. Set to :test for testnet.

Examples

iex> key = BSV.Extended.PrivateKey.from_seed(BSV.Test.bsv_seed)
...> key.__struct__ == BSV.Extended.PrivateKey
true

Converts the given xprv string to an extended private key.

Examples

iex> key = "xprv9s21ZrQH143K2EktC9YxsGeBkkid7yZD7y9gnL7GNkpD6xmF5JoGGgKBQk2tQtA9vAnEfZ6mxhhmULRN5zNwrnDsmX38VGFyBJuhxQPGMsS"
...> |> BSV.Extended.PrivateKey.from_string
...> key.__struct__ == BSV.Extended.PrivateKey
true
Link to this function

get_public_key(private_key, options \\ [])

View Source

Returns the extended public key from the given extended private key.

Examples

iex> key = BSV.Extended.PrivateKey.from_seed(BSV.Test.bsv_seed)
...> |> BSV.Extended.PrivateKey.get_public_key
...> key.__struct__ == BSV.Extended.PublicKey
true

Converts the given extended private key struct to an encoded xprv string.

Examples

iex> BSV.Extended.PrivateKey.from_seed(BSV.Test.bsv_seed)
...> |> BSV.Extended.PrivateKey.to_string
"xprv9s21ZrQH143K2EktC9YxsGeBkkid7yZD7y9gnL7GNkpD6xmF5JoGGgKBQk2tQtA9vAnEfZ6mxhhmULRN5zNwrnDsmX38VGFyBJuhxQPGMsS"