diff --git a/Cargo.lock b/Cargo.lock index 1f88263143..6bbc2b53f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3357,6 +3357,7 @@ name = "minotari_ledger_wallet_common" version = "1.1.0-pre.2" dependencies = [ "bs58 0.5.1", + "tari_utilities", ] [[package]] diff --git a/applications/minotari_ledger_wallet/common/Cargo.toml b/applications/minotari_ledger_wallet/common/Cargo.toml index c0584f20cd..a1c553329c 100644 --- a/applications/minotari_ledger_wallet/common/Cargo.toml +++ b/applications/minotari_ledger_wallet/common/Cargo.toml @@ -6,4 +6,5 @@ license = "BSD-3-Clause" edition = "2021" [dependencies] +tari_utilities = { version = "0.7", default-features = false } bs58 = { version = "0.5.1", default-features = false, features = ["alloc"] } \ No newline at end of file diff --git a/applications/minotari_ledger_wallet/common/src/utils.rs b/applications/minotari_ledger_wallet/common/src/utils.rs index e6c2adf685..1b78f4bb19 100644 --- a/applications/minotari_ledger_wallet/common/src/utils.rs +++ b/applications/minotari_ledger_wallet/common/src/utils.rs @@ -7,6 +7,8 @@ use alloc::{ vec::Vec, }; +use tari_utilities::hex::from_hex; + pub const PUSH_PUBKEY_IDENTIFIER: &str = "217e"; /// Convert a u16 to a string @@ -49,14 +51,7 @@ pub fn hex_to_bytes_serialized(identifier: &str, data: &str) -> Result, } let hex = identifier.to_owned() + data; - let hex = hex.as_str(); - - let mut serialized = Vec::new(); - for i in 0..hex.len() / 2 { - let byte = u8::from_str_radix(&hex[i * 2..i * 2 + 2], 16).map_err(|_e| "Invalid hex string".to_string())?; - serialized.push(byte); - } - Ok(serialized) + from_hex(hex.as_str()).map_err(|e| e.to_string()) } /// The Tari dual address size