pub trait XKeyEncoder {
    fn write_xpub<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
    where
        W: Write,
        K: AsRef<XPub>
; fn write_xpriv<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
    where
        W: Write,
        K: AsRef<XPriv>
; fn read_xpriv<R>(reader: &mut R) -> Result<XPriv, Bip32Error>
    where
        R: Read
; fn read_xpub<R>(reader: &mut R) -> Result<XPub, Bip32Error>
    where
        R: Read
; fn xpriv_to_base58<K>(k: &K) -> Result<String, Bip32Error>
    where
        K: AsRef<XPriv>
, { ... } fn xpub_to_base58<K>(k: &K) -> Result<String, Bip32Error>
    where
        K: AsRef<XPub>
, { ... } fn xpriv_from_base58(s: &str) -> Result<XPriv, Bip32Error> { ... } fn xpub_from_base58(s: &str) -> Result<XPub, Bip32Error> { ... } }
Expand description

Bip32/49/84 encoder

Required Methods

Serialize the xpub to std::io::Write

Serialize the xpriv to std::io::Write

Attempt to instantiate an XPriv from a std::io::Read

use coins_bip32::{Bip32Error, xkeys::XPriv, enc::{XKeyEncoder, MainnetEncoder}};
let xpriv_str = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi".to_owned();

let xpriv: XPriv = MainnetEncoder::xpriv_from_base58(&xpriv_str)?;

Attempt to instantiate an XPub from a std::io::Read

use coins_bip32::{Bip32Error, xkeys::XPub, enc::{XKeyEncoder, MainnetEncoder}};
let xpub_str = "xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y".to_owned();

let xpub: XPub = MainnetEncoder::xpub_from_base58(&xpub_str)?;

Provided Methods

Serialize an XPriv to base58

Serialize an XPub to base58

Attempt to read an XPriv from a b58check string.

use coins_bip32::{Bip32Error, xkeys::XPriv, enc::{XKeyEncoder, MainnetEncoder}};
let xpriv_str = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi".to_owned();

let xpriv: XPriv = MainnetEncoder::xpriv_from_base58(&xpriv_str)?;

Attempt to read an XPub from a b58check string

use coins_bip32::{Bip32Error, xkeys::XPub, enc::{XKeyEncoder, MainnetEncoder}};
let xpub_str = "xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y".to_owned();

let xpub: XPub = MainnetEncoder::xpub_from_base58(&xpub_str)?;

Implementors