Trait coins_bip32::enc::XKeyEncoder
source · pub trait XKeyEncoder {
// Required methods
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;
// Provided methods
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§
sourcefn write_xpub<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>where
W: Write,
K: AsRef<XPub>,
fn write_xpub<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>where W: Write, K: AsRef<XPub>,
Serialize the xpub to std::io::Write
sourcefn write_xpriv<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>where
W: Write,
K: AsRef<XPriv>,
fn write_xpriv<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>where W: Write, K: AsRef<XPriv>,
Serialize the xpriv to std::io::Write
sourcefn read_xpriv<R>(reader: &mut R) -> Result<XPriv, Bip32Error>where
R: Read,
fn read_xpriv<R>(reader: &mut R) -> Result<XPriv, Bip32Error>where R: Read,
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)?;
sourcefn read_xpub<R>(reader: &mut R) -> Result<XPub, Bip32Error>where
R: Read,
fn read_xpub<R>(reader: &mut R) -> Result<XPub, Bip32Error>where R: Read,
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§
sourcefn xpriv_to_base58<K>(k: &K) -> Result<String, Bip32Error>where
K: AsRef<XPriv>,
fn xpriv_to_base58<K>(k: &K) -> Result<String, Bip32Error>where K: AsRef<XPriv>,
Serialize an XPriv to base58
sourcefn xpub_to_base58<K>(k: &K) -> Result<String, Bip32Error>where
K: AsRef<XPub>,
fn xpub_to_base58<K>(k: &K) -> Result<String, Bip32Error>where K: AsRef<XPub>,
Serialize an XPub to base58
sourcefn xpriv_from_base58(s: &str) -> Result<XPriv, Bip32Error>
fn xpriv_from_base58(s: &str) -> Result<XPriv, Bip32Error>
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)?;
sourcefn xpub_from_base58(s: &str) -> Result<XPub, Bip32Error>
fn xpub_from_base58(s: &str) -> Result<XPub, Bip32Error>
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)?;