Skip to content

Commit

Permalink
Avoid using the hex crate in the hd module
Browse files Browse the repository at this point in the history
In the hopes of eventually removing the dependency on hex entirely.
  • Loading branch information
shesek committed Jun 21, 2020
1 parent 26b802b commit a957961
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/hd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,9 @@ impl_string_serializer!(
impl KeyOrigin {
pub fn to_label(&self) -> String {
match self {
KeyOrigin::Derived(parent_fingerprint, index) => format!(
"{}/{}/{}",
LABEL_PREFIX,
hex::encode(parent_fingerprint.as_bytes()),
index
),
KeyOrigin::Derived(parent_fingerprint, index) => {
format!("{}/{}/{}", LABEL_PREFIX, parent_fingerprint, index)
}
KeyOrigin::Standalone => LABEL_PREFIX.into(),
KeyOrigin::DerivedHard(..) => unreachable!(),
}
Expand All @@ -413,7 +410,7 @@ impl KeyOrigin {
let parts: Vec<&str> = s.splitn(3, '/').collect();
match (parts.get(0), parts.get(1), parts.get(2)) {
(Some(&LABEL_PREFIX), Some(parent), Some(index)) => Some(KeyOrigin::Derived(
Fingerprint::from(&hex::decode(parent).ok()?[..]),
Fingerprint::from_str(parent).ok()?,
index.parse().ok()?,
)),
(Some(&LABEL_PREFIX), None, None) => Some(KeyOrigin::Standalone),
Expand Down

0 comments on commit a957961

Please sign in to comment.