#address #lib #blockchain #format #qtum #en-decoding #qtum-ethereum

qtum-address-rust

Rust lib for en/decoding address to Qtum/Ethereum format

3 unstable releases

0.2.0 Apr 30, 2023
0.1.1 Dec 23, 2020
0.1.0 Dec 23, 2020

#162 in #address

GPL-3.0 license

16KB
115 lines

qtum-address-rust

crates.io docs.rs

Rust lib for en/decoding address to Qtum/Ethereum format

Usage

use qtum_address_rust::*;

fn main() {
    let addr = "qTTH1Yr2eKCuDLqfxUyBLCAjmomQ8pyrBt";
    
    let qtum = QtumAddress { prefix: 0x78 }; // testnet network prefix
    let eth_addr = qtum.gethexaddress(addr).unwrap(); // 6c89a1a6ca2ae7c00b248bb2832d6f480f27da68
    let qtum_addr = qtum.fromhexaddress(&eth_addr).unwrap(); // qTTH1Yr2eKCuDLqfxUyBLCAjmomQ8pyrBt
}

lib.rs:

qtum-address-rust

Rust lib for en/decoding address to Qtum/Ethereum format

use qtum_address_rust::*;

let addr = "qTTH1Yr2eKCuDLqfxUyBLCAjmomQ8pyrBt";

let qtum = QtumAddress::new(QtumNetwork::Testnet); // testnet network prefix
let eth_addr = qtum.gethexaddress(addr).unwrap(); // 6c89a1a6ca2ae7c00b248bb2832d6f480f27da68
let qtum_addr = qtum.fromhexaddress(&eth_addr).unwrap(); // qTTH1Yr2eKCuDLqfxUyBLCAjmomQ8pyrBt

assert_eq!(addr, qtum_addr)

Dependencies

~235KB