1 use bitcoin::secp256k1::PublicKey;
4 pub fn to_vec(hex: &str) -> Option<Vec<u8>> {
5 let mut out = Vec::with_capacity(hex.len() / 2);
8 for (idx, c) in hex.as_bytes().iter().enumerate() {
11 b'A'..=b'F' => b |= c - b'A' + 10,
12 b'a'..=b'f' => b |= c - b'a' + 10,
13 b'0'..=b'9' => b |= c - b'0',
26 pub fn hex_str(value: &[u8]) -> String {
27 let mut res = String::with_capacity(2 * value.len());
29 write!(&mut res, "{:02x}", v).expect("Unable to write");
34 pub fn to_compressed_pubkey(hex: &str) -> Option<PublicKey> {
35 if hex.len() != 33 * 2 {
38 let data = match to_vec(&hex[0..33 * 2]) {
42 match PublicKey::from_slice(&data) {