diff --git a/src/util/bip32.rs b/src/util/bip32.rs index 2d8db57f..c28d337a 100644 --- a/src/util/bip32.rs +++ b/src/util/bip32.rs @@ -235,6 +235,18 @@ impl IntoDerivationPath for T where T: Into { } } +impl IntoDerivationPath for String { + fn into_derivation_path(self) -> Result { + self.parse() + } +} + +impl<'a> IntoDerivationPath for &'a str { + fn into_derivation_path(self) -> Result { + self.parse() + } +} + impl From> for DerivationPath { fn from(numbers: Vec) -> Self { DerivationPath(numbers) @@ -831,6 +843,9 @@ mod tests { ChildNumber::from_normal_idx(1000000000).unwrap(), ].into()) ); + let s = "m/0'/50/3'/5/545456"; + assert_eq!(DerivationPath::from_str(s), s.into_derivation_path()); + assert_eq!(DerivationPath::from_str(s), s.to_string().into_derivation_path()); } #[test]