/// Converts a public key hash to its cashaddr address
Converts a public key hash to its cashaddr address
Converts a public key hash to its cashaddr address
pub fn cashaddr_encode(data: &[u8], addr_type: AddressType, network: Network) -> Result<String> {
    let mut version_byte = match addr_type {
        AddressType::P2PKH => version_byte_flags::TYPE_P2PKH,
        AddressType::P2SH => version_byte_flags::TYPE_P2SH,
    };
    let size_flag = match data.len() {
        20 => version_byte_flags::SIZE_160,
        24 => version_byte_flags::SIZE_192,
        28 => version_byte_flags::SIZE_224,
        32 => version_byte_flags::SIZE_256,
        40 => version_byte_flags::SIZE_320,
        48 => version_byte_flags::SIZE_384,
        56 => version_byte_flags::SIZE_448,
        64 => version_byte_flags::SIZE_512,
        _ => {
            let msg = format!("Size is not allowed: {}", data.len());
            return Err(Error::BadArgument(msg));
        }
    };
    version_byte = version_byte | size_flag;
    encode_with_version_byte(data, version_byte, network)
}
pub fn cashaddr_encode ( data : & [ u8 ] , addr_type : AddressType , network : Network ) -> Result < String > { let mut version_byte = match addr_type { AddressType :: P2PKH => version_byte_flags :: TYPE_P2PKH , AddressType :: P2SH => version_byte_flags :: TYPE_P2SH , } ; let size_flag = match data . len ( ) { 20 => version_byte_flags :: SIZE_160 , 24 => version_byte_flags :: SIZE_192 , 28 => version_byte_flags :: SIZE_224 , 32 => version_byte_flags :: SIZE_256 , 40 => version_byte_flags :: SIZE_320 , 48 => version_byte_flags :: SIZE_384 , 56 => version_byte_flags :: SIZE_448 , 64 => version_byte_flags :: SIZE_512 , _ => { let msg = format ! ( " " data len ( ) ) ; return Err ( Error :: BadArgument ( msg ) ) ; } } ; version_byte = version_byte | size_flag ; encode_with_version_byte ( data , version_byte , network ) }
Converts a public key hash to its cashaddr address
Converts a public key hash to its cashaddr address
data
&[u8]
addr_type
AddressType
network
Network