BSV-ex v0.3.0 BSV.Extended.PublicKey View Source

BIP-32 extended public key module.

Link to this section Summary

Types

t()

Extended Public Key

Functions

Converts the given extended private key into an extended public key.

Converts the given xpub string to an extended public key.

Converts the given extended public key struct to an encoded xpub string.

Link to this section Types

Link to this type

t()

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

Extended Public Key

Link to this section Functions

Link to this function

from_private_key(private_key, options \\ [])

View Source
from_private_key(BSV.Extended.PrivateKey.t(), keyword()) :: t()

Converts the given extended private key into an extended public key.

Options

The accepted options are:

  • :compressed - Specify whether to compress the generated public key. Defaults to true.

Examples

iex> key = BSV.Extended.PrivateKey.from_seed(BSV.Test.bsv_seed)
...> |> BSV.Extended.PublicKey.from_private_key
...> key.__struct__ == BSV.Extended.PublicKey
true
Link to this function

from_string(xpub)

View Source
from_string(String.t()) :: t()

Converts the given xpub string to an extended public key.

Examples

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

to_string(public_key)

View Source
to_string(t()) :: String.t()

Converts the given extended public key struct to an encoded xpub string.

Examples

iex> BSV.Extended.PrivateKey.from_seed(BSV.Test.bsv_seed)
...> |> BSV.Extended.PublicKey.from_private_key
...> |> BSV.Extended.PublicKey.to_string
"xpub661MyMwAqRbcEiqMJB5yEQavJnZ7XSH4VC5HaiWsw6MBym6Pcr7WpUdfFykNbZL2JDFFYVe1NpUhJwvaZN44d7R3SmPHSjmUiT8pkR8Yrkk"