BSV-ex v0.2.2 BSV.Extended.PrivateKey View Source
BIP-32 extended private key module.
Link to this section Summary
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
Extended Private Key
Link to this section Functions
Link to this function
from_seed(seed, options \\ [])
View Sourcefrom_seed(binary(), keyword()) :: BSV.Extended.PrivateKey.t()
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
Link to this function
from_string(xprv)
View Sourcefrom_string(String.t()) :: BSV.Extended.PrivateKey.t()
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 Sourceget_public_key(BSV.Extended.PrivateKey.t(), keyword()) :: BSV.Extended.PublicKey.t()
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
Link to this function
to_string(private_key)
View Sourceto_string(BSV.Extended.PrivateKey.t()) :: String.t()
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"