use super::Error;
use keystore::{CryptoType, KeyFile};
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
pub struct HdwalletCrypto {
pub cipher: String,
pub hardware: String,
pub hd_path: String,
}
impl Default for HdwalletCrypto {
fn default() -> HdwalletCrypto {
HdwalletCrypto {
cipher: String::new(),
hardware: String::new(),
hd_path: String::new(),
}
}
}
impl HdwalletCrypto {
pub fn try_from(kf: &KeyFile) -> Result<Self, Error> {
match kf.crypto {
CryptoType::HdWallet(ref hd) => Ok(Self {
cipher: hd.cipher.clone(),
hardware: hd.hardware.clone(),
hd_path: hd.hd_path.clone(),
}),
_ => Err(Error::HDWalletError("HD wallet".to_string())),
}
}
}
impl Into<KeyFile> for HdwalletCrypto {
fn into(self) -> KeyFile {
KeyFile {
crypto: CryptoType::HdWallet(self),
..Default::default()
}
}
}