1 use bitcoin::secp256k1::key::PublicKey;
3 pub fn to_vec(hex: &str) -> Option<Vec<u8>> {
4 let mut out = Vec::with_capacity(hex.len() / 2);
7 for (idx, c) in hex.as_bytes().iter().enumerate() {
10 b'A'..=b'F' => b |= c - b'A' + 10,
11 b'a'..=b'f' => b |= c - b'a' + 10,
12 b'0'..=b'9' => b |= c - b'0',
25 pub fn hex_str(value: &[u8]) -> String {
26 let mut res = String::with_capacity(64);
28 res += &format!("{:02x}", v);
33 pub fn to_compressed_pubkey(hex: &str) -> Option<PublicKey> {
34 let data = match to_vec(&hex[0..33 * 2]) {
38 match PublicKey::from_slice(&data) {