Trait crypto_addr::WIF

source ·
pub trait WIF {
    // Required method
    fn wif(&self, opts: WIFFormat) -> Result<String, Error>;
}
Expand description

Encode a private key using WIF format

Usage

WIFs are generated using WIF::wif

use crypto_addr::{WIF, WIFFormat as WF};
use hex_literal::hex;

const PRVKEY_BYTES: [u8; 32] =
    hex!("fdd662f90c0ad0e8c44fcbeb991365b1a66965265d3b1d1231e988150f3fb4bf");

assert_eq!(PRVKEY_BYTES.wif(WF::Bitcoin).as_deref(),  Ok("L5j8wWT18PsT4uUQPrQmHaG8dbsGTdC6PkEvyngK96QGd1FJXfVt"));
assert_eq!(PRVKEY_BYTES.wif(WF::Litecoin).as_deref(), Ok("TBZQPFkBXmr3qk7GwVMdVvoWaTWaXiCzCx9BqbJri4aS8trGJjAj"));
assert_eq!(PRVKEY_BYTES.wif(WF::Dogecoin).as_deref(), Ok("QX846MFzP1MaJRsSz8FZAo6k6dtqWBKuGzvqmR59sT1d4wJfoMbU"));
assert_eq!(PRVKEY_BYTES.wif(WF::Dash).as_deref(),     Ok("XKo4PmqNS5Vu8EUnRcQdnoT9Yd8quRoLmKaqWK1WTTgN2ASdVNfh"));
assert_eq!(PRVKEY_BYTES.wif(WF::Hex).as_deref(),      Ok("fdd662f90c0ad0e8c44fcbeb991365b1a66965265d3b1d1231e988150f3fb4bf"));

Required Methods§

source

fn wif(&self, opts: WIFFormat) -> Result<String, Error>

Encode private key bytes as a WIF using blockchain parameters given by opts

Implementations on Foreign Types§

source§

impl WIF for [u8]

The input bytes are interpreted as the raw private key in big-endian format.

source§

fn wif(&self, opts: WIFFormat) -> Result<String, Error>

source§

impl WIF for SecretKey

Available on crate feature k256 only.
source§

fn wif(&self, opts: WIFFormat) -> Result<String, Error>

source§

impl WIF for SigningKey

Available on crate feature k256 only.
source§

fn wif(&self, opts: WIFFormat) -> Result<String, Error>

Implementors§

source§

impl WIF for PrvkeyBytes

The input bytes are interpreted as the raw private key in big-endian format.