Skip to main content

Crate earth_codec

Crate earth_codec 

Source
Expand description

Codec

A simple library providing an Address struct enabling encoding/decoding of EARTH addresses.

use earth_codec::{Address, Network, Scheme};

fn main() {
// Decode base58 address
let legacy_addr: &str = "1CM18hbqJzCnM8CaxaNQHxJcnkcYbLV5Gw";
let mut addr = Address::decode(legacy_addr).unwrap();

// Change the base58 address to a test network earth address
addr.network = Network::Test;
addr.scheme = Scheme::Earth;

// Encode earth address
let earth_address: String = addr.encode().unwrap();

println!("{:#?}", earth_address);
// earthtest:qp78r5zdgr53xszxlycksftf95wcv5a8q5khw5038k
}

Structs§

Address
Struct containing the bytes and metadata of a Bitcoin Cash address. This is yeilded during decoding or consumed during encoding.
Base58Codec
Codec allowing the encoding and decoding of base58 addresses
CashAddrCodec
Codec allowing the encoding and decoding of cashaddrs
EarthCodec
Codec allowing the encoding and decoding of earth addresses

Enums§

AddressError
Error concerning encoding/decoding of addresses
Base58Error
Error concerning encoding/decoding of base58 addresses
CashAddrError
Error concerning encoding/decoding of cashaddrs
EarthError
Error concerning encoding/decoding of earth addresses
HashType
Intepretation of the Hash160 bytes
Network
EARTH Networks
Scheme
Address encoding scheme

Traits§

AddressCodec
A trait providing an interface for encoding and decoding the Address struct for each address scheme.