BSV-ex v0.2.2 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

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

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

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"