View Source BitcoinLib.Key.PublicKey.Deserialization (BitcoinLib v0.4.3)

Extended public key deserialization module

To test the results, use https://www.npmjs.com/package/@swan-bitcoin/xpub-cli Serialization types: https://github.com/satoshilabs/slips/blob/master/slip-0132.md

Link to this section Summary

Functions

Deserialization of a public key from its xpub version

Link to this section Functions

@spec deserialize(binary()) ::
  {:ok,
   %BitcoinLib.Key.PublicKey{
     chain_code: term(),
     depth: term(),
     fingerprint: term(),
     index: term(),
     key: term(),
     parent_fingerprint: term(),
     uncompressed_key: term()
   }, :mainnet | :testnet, :bip32 | :bip49 | :bip84}
  | {:error, binary()}

Deserialization of a public key from its xpub version

values from https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vector-1

examples

Examples

iex> "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"
...> |> BitcoinLib.Key.PublicKey.deserialize()
{
  :ok,
  %BitcoinLib.Key.PublicKey{
    key: <<0x339A36013301597DAEF41FBE593A02CC513D0B55527EC2DF1050E2E8FF49C85C2::264>>,
    chain_code: <<0x873DFF81C02F525623FD1FE5167EAC3A55A049DE3D314BB42EE227FFED37D508::256>>,
    depth: 0,
    index: 0,
    parent_fingerprint: <<0,0,0,0>>,
    fingerprint: <<0x3442193e::32>>
  },
  :mainnet,
  :bip32
}